main.py 525 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674
  1. #! /usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. #This file is part of RogueBox Adventures.
  4. #
  5. # RogueBox Adventures is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # RogueBox Adventures is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with RogueBox Adventures. If not, see <http://www.gnu.org/licenses/>.
  17. import datetime
  18. import time
  19. from time import sleep as sleep
  20. import sys
  21. import os
  22. low_res = False
  23. gcwz_input = False
  24. home_save = False
  25. cheat_mode = False
  26. Time_ready = False
  27. entrance_x = 0
  28. entrance_y = 0
  29. basic_path = os.path.dirname(os.path.realpath('main.py')) #just get the execution path for resources
  30. for t in sys.argv:
  31. if t == '-m':
  32. p = os.path.expanduser(basic_path)
  33. lf = open('rba.desktop','w')
  34. lf.write('[Desktop Entry]\n')
  35. lf.write('Type=Application\n')
  36. lf.write('Name=RogueBox Adventures\n')
  37. lf.write('Comment=A RogueBox Game\n')
  38. lf.write('Exec=sh ' + p + os.sep + 'LIB' + os.sep + 'run.sh\n')
  39. lf.write('Icon=' + p + os.sep + 'icon_big.png\n')
  40. lf.write('Terminal=false\n')
  41. lf.write('Categories=Game;')
  42. lf.close()
  43. rf_path = p + os.sep + 'LIB' + os.sep + 'run.sh'
  44. rf = open(rf_path,'w')
  45. rf.write('#This file was generated automatically. Please don\'t change anything.\n')
  46. rf.write('cd ' + p + '\n')
  47. rf.write('python ' + p + os.sep + 'run.py')
  48. sys_com = 'chmod +x ' + p + os.sep + 'rba.desktop'
  49. os.system(sys_com)
  50. exit(0)
  51. if t == '-c':
  52. cheat_mode = True
  53. if t == '-g':
  54. gcwz_input = True
  55. if t == '-h':
  56. home_save = True
  57. lib_path = basic_path + os.sep + 'LIB'
  58. data_path = basic_path + os.sep + 'DATA'
  59. if home_save == False:
  60. save_path = basic_path + os.sep + 'SAVE' + os.sep + 'World0'
  61. else:
  62. save_path = os.path.expanduser('~') + os.sep + '.config' + os.sep + 'RogueBox-Adventures' + os.sep + 'SAVE' + os.sep + 'World0'
  63. path = save_path.replace(os.sep+'World0','')
  64. if os.path.exists(path) == False:
  65. for c in range(0,5):
  66. ph = path + os.sep + 'World' + str(c)
  67. os.makedirs(ph)
  68. del path
  69. playing = False
  70. sys.path.append(lib_path)
  71. max_map_size = 52
  72. monitor = [0,0]
  73. try:
  74. import cPickle as p
  75. except:
  76. import pickle as p
  77. try:
  78. p.DEFAULT_PROTOCOL=0
  79. except:
  80. p.HIGHEST_PROTOCOL=0
  81. import random
  82. if gcwz_input == True:
  83. from getch_gcwz import *
  84. else:
  85. from getch import *
  86. from tile import tile
  87. from attribute import attribute
  88. from item import *
  89. from countdown import *
  90. import pygame
  91. from gra_files import *
  92. from util import *
  93. from monster import monster
  94. from copy import deepcopy
  95. from buffs import buffs
  96. from itemlist import *
  97. from tilelist import *
  98. from monsterlist import *
  99. from text import texts
  100. from skill import *
  101. from dialog import *
  102. from version import *
  103. game_options = game_options(basic_path,home_save)
  104. if game_options.check_version == 1:
  105. ver_string = check_version()
  106. else:
  107. ver_string = ' '
  108. class g_screen():
  109. def __init__(self, mode = game_options.screenmode, show_logo = True):
  110. string = 'RogueBoxAdventures ' + version +' "'+version_name+'"'
  111. pygame.display.set_caption(string)
  112. icon = pygame.image.load('icon_small.png')
  113. pygame.display.set_icon(icon)
  114. global monitor
  115. self.fire_mode = 0 #0: normal, 1: fire
  116. self.win_mode = mode
  117. self.hit_matrix = []
  118. for y in range(0,12):
  119. self.hit_matrix.append([])
  120. for x in range(0,15):
  121. self.hit_matrix[y].append(0)
  122. pygame.init()
  123. display_info = pygame.display.Info()
  124. if monitor == [0,0]:
  125. monitor[0] = display_info.current_w
  126. monitor[1] = display_info.current_h
  127. self.displayx = monitor[0]
  128. self.displayy = monitor[1]
  129. #check if the screenmode is 16:9
  130. self.displayx = monitor[0]-monitor[0]%640
  131. self.displayy = monitor[1]-monitor[1]%360
  132. winstyle = pygame.FULLSCREEN
  133. if cheat_mode == True and self.win_mode == 2:
  134. self.win_mode = 1 #disable fullscreen in cheat mode
  135. if self.win_mode == 2:
  136. self.screen = pygame.display.set_mode((self.displayx,self.displayy),winstyle)
  137. pygame.mouse.set_visible(game_options.mousepad)
  138. elif self.win_mode == 0 and low_res == False:
  139. self.screen = pygame.display.set_mode((640,360))
  140. self.displayx = 640
  141. self.displayy = 360
  142. elif self.win_mode == 1 and low_res == False:
  143. self.screen = pygame.display.set_mode((1280,720))
  144. self.displayx = 1280
  145. self.displayy = 720
  146. font_path = basic_path + os.sep + 'FONT' + os.sep + 'PressStart2P.ttf'
  147. self.font = pygame.font.Font(font_path,8)
  148. if low_res == True:
  149. str_ext = '_low_res'
  150. else:
  151. str_ext = ''
  152. if __name__ == '__main__':
  153. show_logo = False
  154. if show_logo == True:
  155. display_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep
  156. ran = random.randint(0,4)
  157. i_name = display_path + 'logo' + str(ran) + str_ext + '.png'
  158. i = pygame.image.load(i_name)
  159. i = pygame.transform.scale(i,(self.displayx,self.displayy))
  160. self.screen.blit(i,(0,0))
  161. pygame.display.flip()
  162. getch(640,360,mode=1)
  163. display_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep
  164. ran = random.randint(0,4)
  165. i_name = display_path + 'logo_gpl' + str_ext + '.png'
  166. i = pygame.image.load(i_name)
  167. i = pygame.transform.scale(i,(self.displayx,self.displayy))
  168. self.screen.blit(i,(0,0))
  169. pygame.display.flip()
  170. getch(640,360,mode=1)
  171. display_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep
  172. i_name = display_path + 'oga' + str_ext + '.png'
  173. i = pygame.image.load(i_name)
  174. i = pygame.transform.scale(i,(self.displayx,self.displayy))
  175. self.screen.blit(i,(0,0))
  176. pygame.display.flip()
  177. getch(640,360,mode=1)
  178. def render_fade(self,fadeout,fadein,menu='default'):
  179. if menu == 'inventory':
  180. bg = player.inventory.render(0,0,simulate=True)
  181. elif menu == 'screen':
  182. bg = screen.screen
  183. elif menu == 'loot':
  184. bg = world.maplist[player.pos[2]][player.on_map].containers[player.pos[1]][player.pos[0]].inventory(simulated=True)
  185. elif menu == 'brake':
  186. bg = screen.render_brake(simulate=True)
  187. elif menu == 'main':
  188. bg = screen.render_main_menu(simulate=True)
  189. else:
  190. bg = self.render(0,True)
  191. clock = pygame.time.Clock()
  192. if fadein:
  193. for i in range(255,0,-15):
  194. helpsur = pygame.Surface((self.displayx,self.displayy))
  195. helpsur.fill((48,48,48))
  196. helpsur.set_alpha(i)
  197. self.screen.blit(bg,(0,0))
  198. self.screen.blit(helpsur,(0,0))
  199. pygame.display.flip()
  200. clock.tick(510)
  201. if fadeout:
  202. for i in range(0,255,15):
  203. helpsur = pygame.Surface((self.displayx,self.displayy))
  204. helpsur.fill((48,48,48))
  205. helpsur.set_alpha(i)
  206. self.screen.blit(bg,(0,0))
  207. self.screen.blit(helpsur,(0,0))
  208. pygame.display.flip()
  209. clock.tick(510)
  210. def reset_hit_matrix(self):
  211. self.hit_matrix = []
  212. for y in range(0,12):
  213. self.hit_matrix.append([])
  214. for x in range(0,15):
  215. self.hit_matrix[y].append(0)
  216. def write_hit_matrix(self,x,y,style):
  217. #style: 0:nothing
  218. # 1:fire_path
  219. # 2:fire_path_monster
  220. # 3:miss
  221. # 4:hit
  222. # 5:critical
  223. # 6:heal
  224. # 7:teleport
  225. # 8:minus_gem
  226. # 9:plus_gem
  227. # 10:plus_fish
  228. # 11:plus_shoe
  229. # 12:monster_lvl_up
  230. # 13:monster_die
  231. # 14:attention
  232. # 15:found
  233. # 16:drop
  234. # 17:fear
  235. # 18:blood_minus
  236. # 19:blood_plus
  237. # 20:throw
  238. # 21:minus_item
  239. # 22:plus_item
  240. # 23:spellwave
  241. # 24:wait
  242. # 25:sleep
  243. xx = x - player.pos[0] + 8
  244. yy = y - player.pos[1] + 6
  245. try:
  246. if xx >= 0 and yy >= 0:
  247. self.hit_matrix[yy][xx] = style
  248. except:
  249. None
  250. def render_hits(self):
  251. s = pygame.Surface((480,360))
  252. s.fill((255,0,255))
  253. start = 0
  254. for y in range(start,len(self.hit_matrix)):
  255. for x in range(start,len(self.hit_matrix[0])):
  256. if self.hit_matrix[y][x] == 1:
  257. s.blit(gra_files.gdic['display'][11],(((x-start)*32),(y-start)*32))
  258. elif self.hit_matrix[y][x] == 2:
  259. s.blit(gra_files.gdic['display'][12],(((x-start)*32),(y-start)*32))
  260. elif self.hit_matrix[y][x] == 3:
  261. s.blit(gra_files.gdic['display'][13],(((x-start)*32),(y-start)*32))
  262. elif self.hit_matrix[y][x] == 4:
  263. s.blit(gra_files.gdic['display'][14],(((x-start)*32),(y-start)*32))
  264. elif self.hit_matrix[y][x] == 5:
  265. s.blit(gra_files.gdic['display'][15],(((x-start)*32),(y-start)*32))
  266. elif self.hit_matrix[y][x] == 6:
  267. s.blit(gra_files.gdic['display'][23],(((x-start)*32),(y-start)*32))
  268. elif self.hit_matrix[y][x] == 7:
  269. s.blit(gra_files.gdic['display'][24],(((x-start)*32),(y-start)*32))
  270. elif self.hit_matrix[y][x] == 8:
  271. s.blit(gra_files.gdic['display'][26],(((x-start)*32),(y-start)*32))
  272. elif self.hit_matrix[y][x] == 9:
  273. s.blit(gra_files.gdic['display'][27],(((x-start)*32),(y-start)*32))
  274. elif self.hit_matrix[y][x] == 10:
  275. s.blit(gra_files.gdic['display'][42],(((x-start)*32),(y-start)*32))
  276. elif self.hit_matrix[y][x] == 11:
  277. s.blit(gra_files.gdic['display'][43],(((x-start)*32),(y-start)*32))
  278. elif self.hit_matrix[y][x] == 12:
  279. s.blit(gra_files.gdic['display'][51],(((x-start)*32),(y-start)*32))
  280. elif self.hit_matrix[y][x] == 13:
  281. s.blit(gra_files.gdic['display'][58],(((x-start)*32),(y-start)*32))
  282. elif self.hit_matrix[y][x] == 14:
  283. s.blit(gra_files.gdic['display'][59],(((x-start)*32),(y-start)*32))
  284. elif self.hit_matrix[y][x] == 15:
  285. s.blit(gra_files.gdic['display'][60],(((x-start)*32),(y-start)*32))
  286. elif self.hit_matrix[y][x] == 16:
  287. s.blit(gra_files.gdic['display'][61],(((x-start)*32),(y-start)*32))
  288. elif self.hit_matrix[y][x] == 17:
  289. s.blit(gra_files.gdic['display'][62],(((x-start)*32),(y-start)*32))
  290. elif self.hit_matrix[y][x] == 18:
  291. s.blit(gra_files.gdic['display'][63],(((x-start)*32),(y-start)*32))
  292. elif self.hit_matrix[y][x] == 19:
  293. s.blit(gra_files.gdic['display'][64],(((x-start)*32),(y-start)*32))
  294. elif self.hit_matrix[y][x] == 20:
  295. s.blit(gra_files.gdic['display'][65],(((x-start)*32),(y-start)*32))
  296. elif self.hit_matrix[y][x] == 21:
  297. s.blit(gra_files.gdic['display'][66],(((x-start)*32),(y-start)*32))
  298. elif self.hit_matrix[y][x] == 22:
  299. s.blit(gra_files.gdic['display'][67],(((x-start)*32),(y-start)*32))
  300. elif self.hit_matrix[y][x] == 23:
  301. s.blit(gra_files.gdic['display'][70],(((x-start)*32),(y-start)*32))
  302. elif self.hit_matrix[y][x] == 24:
  303. s.blit(gra_files.gdic['display'][69],(((x-start)*32),(y-start)*32))
  304. elif self.hit_matrix[y][x] == 25:
  305. s.blit(gra_files.gdic['display'][75],(((x-start)*32),(y-start)*32))
  306. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  307. s = s.convert_alpha()
  308. return s
  309. def render_main_menu(self,simulate=False):
  310. if simulate == False:
  311. screen.render_fade(False,True,'main')
  312. if home_save == False:
  313. display_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep
  314. alt_path = display_path
  315. else:
  316. display_path = os.path.expanduser('~') + os.sep + '.config' + os.sep + 'RogueBox-Adventures' + os.sep
  317. alt_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep
  318. num = 0
  319. master_loop = True
  320. run = True
  321. while run:
  322. s = pygame.Surface((640,360))
  323. s.fill((48,48,48))
  324. try:
  325. i_name = display_path + 'tmp.png'
  326. i = pygame.image.load(i_name)
  327. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  328. i = i.convert_alpha()
  329. s.blit(i,(0,0))
  330. except:
  331. i_name = alt_path + 'alt.png'
  332. i = pygame.image.load(i_name)
  333. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  334. i = i.convert_alpha()
  335. s.blit(i,(0,0))
  336. s.blit(gra_files.gdic['display'][16],(0,0))
  337. menu_list = ('PLAY','OPTIONS','CREDITS','QUIT')
  338. for c in range(0,len(menu_list)):
  339. name_image = self.font.render(menu_list[c],1,(0,0,0))
  340. s.blit(name_image,(210,145+(c*45)))
  341. s.blit(gra_files.gdic['display'][4],(185,138+(num*45)))
  342. version_info = 'v'+version+' "'+version_name+'"'
  343. ver_info_image1 = self.font.render(version_info,1,(0,0,0))
  344. ver_info_image2 = self.font.render(version_info,1,(255,255,255))
  345. s.blit(ver_info_image1,(107,85))
  346. s.blit(ver_info_image2,(105,85))
  347. if game_options.check_version == 1:
  348. if ver_string == 'This version is up to date.':
  349. ver_image = self.font.render(ver_string,1,(0,255,0))
  350. elif ver_string == 'Old version!!! Please update.':
  351. ver_image = self.font.render(ver_string,1,(255,0,0))
  352. else:
  353. ver_image = self.font.render(ver_string,1,(255,255,255))
  354. ver_image2 = self.font.render(ver_string,1,(0,0,0))
  355. s.blit(ver_image2,(12,340))
  356. s.blit(ver_image,(10,340))
  357. if game_options.mousepad == 0:
  358. s_h = pygame.Surface((160,360))
  359. s_h.fill((48,48,48))
  360. s.blit(s_h,(480,0))
  361. s_help = pygame.Surface((640,360))
  362. s_help.fill((48,48,48))
  363. s_help.blit(s,(80,0))
  364. s = s_help
  365. else:
  366. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  367. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  368. if simulate == True:
  369. return s
  370. self.screen.blit(s,(0,0))
  371. pygame.display.flip()
  372. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  373. if ui == 'exit':
  374. master_loop = False
  375. run = False
  376. if ui == 'w':
  377. num -= 1
  378. if num < 0:
  379. num = 0
  380. elif ui == 's':
  381. num += 1
  382. if num > 3:
  383. num = 3
  384. elif ui == 'e':
  385. if num == 0:
  386. test = screen.choose_save_path()
  387. if test == 'exit':
  388. master_loop = False
  389. run = False
  390. elif num == 1:
  391. test = screen.render_options()
  392. if test == 'exit':
  393. master_loop = False
  394. run = False
  395. elif num == 2:
  396. test = screen.render_credits()
  397. if test == 'exit':
  398. master_loop = False
  399. run = False
  400. elif num == 3:
  401. master_loop = False
  402. run = False
  403. return master_loop
  404. def render_crash(self):
  405. run = True
  406. while run:
  407. self.screen.fill((48,48,48))
  408. string = []
  409. string.append('Sorry, something went wrong.')
  410. string.append('Check out debug.txt for more informations.')
  411. debug_location = '('+save_path+')'
  412. for c in range(0,6):
  413. debug_location = debug_location.replace('World'+str(c),'debug.txt')
  414. string.append(debug_location)
  415. st = []
  416. for i in string:
  417. st.append(self.font.render(i,1,(255,255,255)))
  418. for j in range(0,len(st)):
  419. self.screen.blit(st[j],(5,25+j*25))
  420. pygame.display.flip()
  421. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  422. if ui != 'none':
  423. run = False
  424. def choose_save_path(self):
  425. global save_path
  426. global playing
  427. global master_loop
  428. global gra_files
  429. gra_files = g_files()
  430. if home_save == True:
  431. path = os.path.expanduser('~') + os.sep + '.config' + os.sep + 'RogueBox-Adventures'
  432. else:
  433. path = basic_path
  434. run = True
  435. while run:
  436. menu_items = []
  437. for c in range(0,5):
  438. save_path = path + os.sep + 'SAVE' + os.sep + 'World' + str(c)
  439. p_attribute = attribute(2,2,2,2,2,10,10)
  440. p_inventory = inventory()
  441. player_help = player_class ('-EMPTY SLOT-', 'local_0_0', p_attribute,p_inventory, build= 'Auto')
  442. if player_help.name != '-EMPTY SLOT-':
  443. item_string = player_help.name + ' LVL:' + str(player_help.lvl)
  444. else:
  445. item_string = '-EMPTY SLOT-'
  446. menu_items.append(item_string)
  447. menu_items.append('~~ERASE~~')
  448. menu_items.append('~~BACK~~')
  449. choice = screen.get_choice('Choose a saved game',menu_items,False)
  450. if choice == 'exit':
  451. master_loop = False
  452. run = False
  453. return('exit')
  454. if choice < 5:
  455. save_path = path + os.sep + 'SAVE' + os.sep + 'World' + str(choice)
  456. playing = True
  457. run = False
  458. elif choice == 5:
  459. menu_items_erase = []
  460. for d in range(0,5):
  461. menu_items_erase.append(menu_items[d])
  462. menu_items_erase.append('~~BACK~~')
  463. choice2 = screen.get_choice('Choose a game to erase',menu_items_erase,False,'Warning')
  464. if choice2 < 5:
  465. save_path = path + os.sep + 'SAVE' + os.sep + 'World' + str(choice2)
  466. try:
  467. choice3 = screen.get_choice('Are you sure?',('No','Yes'),False,'Warning')
  468. if choice3 == 1:
  469. h = ('world.data','time.data','player.data','gods.data')
  470. for i in h:
  471. p = save_path + os.sep + i
  472. os.remove(p)
  473. except:
  474. None
  475. elif choice == 6:
  476. run = False
  477. def save_tmp_png(self):
  478. x = player.pos[0]
  479. if x-10 < 0:
  480. x += -1*(x-11)
  481. elif x+10 > max_map_size-2:
  482. x -= 10
  483. y = player.pos[1]
  484. if y-10 < 0:
  485. y += -1*(y-11)
  486. elif y+10 > max_map_size-2:
  487. y -= 10
  488. z = player.pos[2]
  489. s = pygame.Surface((480,360))
  490. for yy in range(-5,10):
  491. for xx in range(-7,8):
  492. try:
  493. s.blit(screen.draw_tile(player.on_map,x+xx,y+yy,z,True),((xx+7)*32,(yy+5)*32))
  494. except:
  495. None
  496. if home_save == False:
  497. tmp_save_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep + 'tmp.png'
  498. else:
  499. tmp_save_path = os.path.expanduser('~') + os.sep + '.config' + os.sep + 'RogueBox-Adventures' + os.sep + 'tmp.png'
  500. pygame.image.save(s,tmp_save_path)
  501. def re_init(self): # For changing screenmode
  502. options_path = save_path.replace(os.sep + 'World0','')
  503. if game_options.screenmode == 2 and cheat_mode == True:
  504. game_options.screenmode = 0
  505. mode = game_options.screenmode
  506. if self.win_mode < 2:
  507. mode += 1
  508. else:
  509. mode = 0
  510. if mode == 2 and cheat_mode == True:
  511. mode = 0
  512. game_options.screenmode = mode
  513. save_options(game_options,options_path,os.sep)
  514. self.__init__(game_options.screenmode,False)
  515. def draw_player(self):
  516. s = pygame.Surface((32,32))
  517. s.fill((255,0,255))
  518. if player.inventory.wearing['Background'] != player.inventory.nothing:
  519. s.blit(gra_files.gdic['clothe'][player.inventory.wearing['Background'].gra_pos[player.gender][0]][player.inventory.wearing['Background'].gra_pos[player.gender][1]],(0,0))
  520. skinstring = 'SKIN_' + player.gender + '_' + str(player.style +1)
  521. s.blit(gra_files.gdic['char'][skinstring],(0,0))
  522. if player.inventory.wearing['Clothing'] == player.inventory.nothing:
  523. underwear_string = player.gender + '_underwear'
  524. s.blit(gra_files.gdic['char'][underwear_string],(0,0))
  525. try:
  526. render_hair = (player.inventory.wearing['Hat'].override_hair == False)
  527. except:
  528. render_hair = True
  529. if player.inventory.wearing['Head'] == player.inventory.nothing and render_hair:
  530. hairstring = 'HAIR_' + player.gender + '_' + str(player.style +1)
  531. s.blit(gra_files.gdic['char'][hairstring],(0,0))
  532. if player.inventory.wearing['Hat'] != player.inventory.nothing:
  533. s.blit(gra_files.gdic['clothe'][player.inventory.wearing['Hat'].gra_pos[player.gender][0]][player.inventory.wearing['Hat'].gra_pos[player.gender][1]],(0,0))
  534. else:
  535. if player.inventory.wearing['Hat'] == player.inventory.nothing:
  536. if player.inventory.wearing['Head'] != player.inventory.nothing:
  537. helmetstring = player.gender + '_' + player.inventory.wearing['Head'].material + '_' + player.inventory.wearing['Head'].classe
  538. s.blit(gra_files.gdic['char'][helmetstring],(0,0))
  539. else:
  540. if render_hair == True:
  541. hairstring = 'HAIR_' + player.gender + '_' + str(player.style +1)
  542. s.blit(gra_files.gdic['char'][hairstring],(0,0))
  543. s.blit(gra_files.gdic['clothe'][player.inventory.wearing['Hat'].gra_pos[player.gender][0]][player.inventory.wearing['Hat'].gra_pos[player.gender][1]],(0,0))
  544. if player.inventory.wearing['Clothing'] == player.inventory.nothing:
  545. if player.inventory.wearing['Body'] != player.inventory.nothing:
  546. armorstring = player.gender + '_' + player.inventory.wearing['Body'].material + '_' + player.inventory.wearing['Body'].classe
  547. s.blit(gra_files.gdic['char'][armorstring],(0,0))
  548. if player.inventory.wearing['Legs'] != player.inventory.nothing:
  549. cuissestring = player.gender + '_' + player.inventory.wearing['Legs'].material + '_' + player.inventory.wearing['Legs'].classe
  550. s.blit(gra_files.gdic['char'][cuissestring],(0,0))
  551. if player.inventory.wearing['Feet'] != player.inventory.nothing:
  552. shoestring = player.gender + '_' + player.inventory.wearing['Feet'].material + '_' + player.inventory.wearing['Feet'].classe
  553. s.blit(gra_files.gdic['char'][shoestring],(0,0))
  554. else:
  555. s.blit(gra_files.gdic['clothe'][player.inventory.wearing['Clothing'].gra_pos[player.gender][0]][player.inventory.wearing['Clothing'].gra_pos[player.gender][1]],(0,0))
  556. if player.inventory.wearing['Hold(R)'] != player.inventory.nothing:
  557. weaponstring = 'WEAPONS_' + player.inventory.wearing['Hold(R)'].material + '_' + player.inventory.wearing['Hold(R)'].classe
  558. s.blit(gra_files.gdic['char'][weaponstring],(0,0))
  559. if player.inventory.wearing['Hold(L)'] != player.inventory.nothing:
  560. weaponstring = 'WEAPONS_' + player.inventory.wearing['Hold(L)'].material + '_' + player.inventory.wearing['Hold(L)'].classe
  561. s.blit(gra_files.gdic['char'][weaponstring],(0,0))
  562. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]][player.pos[0]].move_group == 'low_liquid':
  563. help_s = pygame.Surface((32,5))
  564. help_s.fill((255,0,255))
  565. s.blit(help_s,(0,27))
  566. elif world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]][player.pos[0]].move_group == 'swim':
  567. help_s = pygame.Surface((32,13))
  568. help_s.fill((255,0,255))
  569. s.blit(help_s,(0,19))
  570. if player.buffs.get_buff('invisible') > 0:
  571. s.set_alpha(120)
  572. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  573. return s
  574. def draw_tile(self,on_map,x,y,z,visible):
  575. s = pygame.Surface((32,32))
  576. s.fill((48,48,48))
  577. if x > max_map_size-1 or y > max_map_size-1 or x < 0 or y < 0:
  578. return s
  579. if world.maplist[z][on_map].known[y][x] == 0:
  580. s.blit(gra_files.gdic['tile32'][0][3],(0,0))
  581. else:
  582. if world.maplist[z][on_map].tilemap[y][x].replace != None:
  583. old_tile = world.maplist[z][on_map].tilemap[y][x]
  584. new_tile = world.maplist[z][on_map].tilemap[y][x]
  585. run = True
  586. while run:
  587. new_tile = old_tile.replace
  588. if new_tile != None:
  589. old_tile = new_tile
  590. else:
  591. run = False
  592. if len(old_tile.tile_pos) > 2:
  593. if time.minute%2 == 0:
  594. s.blit(gra_files.gdic['tile32'][old_tile.tile_pos[1]][old_tile.tile_pos[0]],(0,0))
  595. else:
  596. s.blit(gra_files.gdic['tile32'][old_tile.tile_pos[3]][old_tile.tile_pos[2]],(0,0))
  597. else:
  598. s.blit(gra_files.gdic['tile32'][old_tile.tile_pos[1]][old_tile.tile_pos[0]],(0,0))
  599. if len(world.maplist[z][on_map].tilemap[y][x].tile_pos) > 2:
  600. if time.minute%2 == 0:
  601. s.blit(gra_files.gdic['tile32'][world.maplist[z][on_map].tilemap[y][x].tile_pos[1]][world.maplist[z][on_map].tilemap[y][x].tile_pos[0]],(0,0))
  602. else:
  603. s.blit(gra_files.gdic['tile32'][world.maplist[z][on_map].tilemap[y][x].tile_pos[3]][world.maplist[z][on_map].tilemap[y][x].tile_pos[2]],(0,0))
  604. else:
  605. s.blit(gra_files.gdic['tile32'][world.maplist[z][on_map].tilemap[y][x].tile_pos[1]][world.maplist[z][on_map].tilemap[y][x].tile_pos[0]],(0,0))
  606. if game_options.rendermode == 0:
  607. try:
  608. if gra_files.gdic['border'][world.maplist[z][on_map].tilemap[y][x].tile_pos[1]][world.maplist[z][on_map].tilemap[y][x].tile_pos[0]] != False:
  609. if x > 0 and world.maplist[z][on_map].tilemap[y][x-1].move_group != world.maplist[z][on_map].tilemap[y][x].move_group and world.maplist[z][on_map].known[y][x-1] == 1:
  610. s.blit(gra_files.gdic['border'][world.maplist[z][on_map].tilemap[y][x].tile_pos[1]][world.maplist[z][on_map].tilemap[y][x].tile_pos[0]]['v'],(0,0))
  611. if x < max_map_size and world.maplist[z][on_map].tilemap[y][x+1].move_group != world.maplist[z][on_map].tilemap[y][x].move_group and world.maplist[z][on_map].known[y][x+1] == 1:
  612. s.blit(gra_files.gdic['border'][world.maplist[z][on_map].tilemap[y][x].tile_pos[1]][world.maplist[z][on_map].tilemap[y][x].tile_pos[0]]['v'],(30,0))
  613. if y > 0 and world.maplist[z][on_map].tilemap[y-1][x].move_group != world.maplist[z][on_map].tilemap[y][x].move_group and world.maplist[z][on_map].known[y-1][x] == 1:
  614. s.blit(gra_files.gdic['border'][world.maplist[z][on_map].tilemap[y][x].tile_pos[1]][world.maplist[z][on_map].tilemap[y][x].tile_pos[0]]['h'],(0,0))
  615. if y < max_map_size and world.maplist[z][on_map].tilemap[y+1][x].move_group != world.maplist[z][on_map].tilemap[y][x].move_group and world.maplist[z][on_map].known[y+1][x] == 1:
  616. s.blit(gra_files.gdic['border'][world.maplist[z][on_map].tilemap[y][x].tile_pos[1]][world.maplist[z][on_map].tilemap[y][x].tile_pos[0]]['h'],(0,30))
  617. if x > 0 and y > 0 and world.maplist[z][on_map].tilemap[y-1][x-1].move_group != world.maplist[z][on_map].tilemap[y][x].move_group and world.maplist[z][on_map].known[y-1][x-1] == 1:
  618. s.blit(gra_files.gdic['border'][world.maplist[z][on_map].tilemap[y][x].tile_pos[1]][world.maplist[z][on_map].tilemap[y][x].tile_pos[0]]['c'],(0,0))
  619. if x < max_map_size and y > 0 and world.maplist[z][on_map].tilemap[y-1][x+1].move_group != world.maplist[z][on_map].tilemap[y][x].move_group and world.maplist[z][on_map].known[y-1][x+1] == 1:
  620. s.blit(gra_files.gdic['border'][world.maplist[z][on_map].tilemap[y][x].tile_pos[1]][world.maplist[z][on_map].tilemap[y][x].tile_pos[0]]['c'],(30,0))
  621. if x > 0 and y < max_map_size and world.maplist[z][on_map].tilemap[y+1][x-1].move_group != world.maplist[z][on_map].tilemap[y][x].move_group and world.maplist[z][on_map].known[y+1][x-1] == 1:
  622. s.blit(gra_files.gdic['border'][world.maplist[z][on_map].tilemap[y][x].tile_pos[1]][world.maplist[z][on_map].tilemap[y][x].tile_pos[0]]['c'],(0,30))
  623. if x < max_map_size and y < max_map_size and world.maplist[z][on_map].tilemap[y+1][x+1].move_group != world.maplist[z][on_map].tilemap[y][x].move_group and world.maplist[z][on_map].known[y+1][x+1] == 1:
  624. s.blit(gra_files.gdic['border'][world.maplist[z][on_map].tilemap[y][x].tile_pos[1]][world.maplist[z][on_map].tilemap[y][x].tile_pos[0]]['c'],(30,30))
  625. except:
  626. None
  627. if world.maplist[z][on_map].tilemap[y][x].move_group == 'low_liquid' or world.maplist[z][on_map].tilemap[y][x].move_group == 'swim':
  628. if world.maplist[z][on_map].tilemap[y][x-1].replace != None:
  629. try:
  630. if world.maplist[z][on_map].tilemap[y][x-1].replace.ignore_liquid == True:
  631. mgw = 'solid'
  632. else:
  633. mgw = world.maplist[z][on_map].tilemap[y][x-1].replace.move_group
  634. except:
  635. mgw = world.maplist[z][on_map].tilemap[y][x-1].replace.move_group
  636. else:
  637. try:
  638. if world.maplist[z][on_map].tilemap[y][x-1].ignore_liquid == True:
  639. mgw = 'solid'
  640. else:
  641. mgw = world.maplist[z][on_map].tilemap[y][x-1].move_group
  642. except:
  643. mgw = world.maplist[z][on_map].tilemap[y][x-1].move_group
  644. if world.maplist[z][on_map].tilemap[y][x+1].replace != None:
  645. try:
  646. if world.maplist[z][on_map].tilemap[y][x+1].replace.ignore_liquid == True:
  647. mge = 'solid'
  648. else:
  649. mge = world.maplist[z][on_map].tilemap[y][x+1].replace.move_group
  650. except:
  651. mge = world.maplist[z][on_map].tilemap[y][x+1].replace.move_group
  652. else:
  653. try:
  654. if world.maplist[z][on_map].tilemap[y][x+1].ignore_liquid == True:
  655. mge = 'solid'
  656. else:
  657. mge = world.maplist[z][on_map].tilemap[y][x+1].move_group
  658. except:
  659. mge = world.maplist[z][on_map].tilemap[y][x+1].move_group
  660. if world.maplist[z][on_map].tilemap[y-1][x].replace != None:
  661. try:
  662. if world.maplist[z][on_map].tilemap[y-1][x].replace.ignore_liquid == True:
  663. mgn = 'solid'
  664. else:
  665. mgn = world.maplist[z][on_map].tilemap[y-1][x].replace.move_group
  666. except:
  667. mgn = world.maplist[z][on_map].tilemap[y-1][x].replace.move_group
  668. else:
  669. try:
  670. if world.maplist[z][on_map].tilemap[y-1][x].ignore_liquid == True:
  671. mgn = 'solid'
  672. else:
  673. mgn = world.maplist[z][on_map].tilemap[y-1][x].move_group
  674. except:
  675. mgn = world.maplist[z][on_map].tilemap[y-1][x].move_group
  676. if world.maplist[z][on_map].tilemap[y+1][x].replace != None:
  677. try:
  678. if world.maplist[z][on_map].tilemap[y+1][x].replace.ignore_liquid == True:
  679. mgs = 'solid'
  680. else:
  681. mgs = world.maplist[z][on_map].tilemap[y+1][x].replace.move_group
  682. except:
  683. mgs = world.maplist[z][on_map].tilemap[y+1][x].replace.move_group
  684. else:
  685. try:
  686. if world.maplist[z][on_map].tilemap[y+1][x].ignore_liquid == True:
  687. mgs = 'solid'
  688. else:
  689. mgs = world.maplist[z][on_map].tilemap[y+1][x].move_group
  690. except:
  691. mgs = world.maplist[z][on_map].tilemap[y+1][x].move_group
  692. if mgw == 'soil' or mgw == 'low_liquid':
  693. hs = pygame.Surface((32,32))
  694. if world.maplist[z][on_map].tilemap[y][x-1].replace == None:
  695. hs.blit(gra_files.gdic['tile32'][world.maplist[z][on_map].tilemap[y][x-1].tile_pos[1]][world.maplist[z][on_map].tilemap[y][x-1].tile_pos[0]],(0,0))
  696. else:
  697. hs.blit(gra_files.gdic['tile32'][world.maplist[z][on_map].tilemap[y][x-1].replace.tile_pos[1]][world.maplist[z][on_map].tilemap[y][x-1].replace.tile_pos[0]],(0,0))
  698. if time.minute%2 == 0:
  699. hs.blit(gra_files.gdic['edge']['w1'],(0,0))
  700. else:
  701. hs.blit(gra_files.gdic['edge']['w2'],(0,0))
  702. hs.set_colorkey((255,255,255),pygame.RLEACCEL)
  703. hs = hs.convert_alpha()
  704. s.blit(hs,(0,0))
  705. if mge == 'soil' or mge == 'low_liquid':
  706. hs = pygame.Surface((32,32))
  707. if world.maplist[z][on_map].tilemap[y][x+1].replace == None:
  708. hs.blit(gra_files.gdic['tile32'][world.maplist[z][on_map].tilemap[y][x+1].tile_pos[1]][world.maplist[z][on_map].tilemap[y][x+1].tile_pos[0]],(0,0))
  709. else:
  710. hs.blit(gra_files.gdic['tile32'][world.maplist[z][on_map].tilemap[y][x+1].replace.tile_pos[1]][world.maplist[z][on_map].tilemap[y][x+1].replace.tile_pos[0]],(0,0))
  711. if time.minute%2 == 0:
  712. hs.blit(gra_files.gdic['edge']['e1'],(0,0))
  713. else:
  714. hs.blit(gra_files.gdic['edge']['e2'],(0,0))
  715. hs.set_colorkey((255,255,255),pygame.RLEACCEL)
  716. hs = hs.convert_alpha()
  717. s.blit(hs,(0,0))
  718. if mgn == 'soil' or mgn == 'low_liquid':
  719. hs = pygame.Surface((32,32))
  720. if world.maplist[z][on_map].tilemap[y-1][x].replace == None:
  721. hs.blit(gra_files.gdic['tile32'][world.maplist[z][on_map].tilemap[y-1][x].tile_pos[1]][world.maplist[z][on_map].tilemap[y-1][x].tile_pos[0]],(0,0))
  722. else:
  723. hs.blit(gra_files.gdic['tile32'][world.maplist[z][on_map].tilemap[y-1][x].replace.tile_pos[1]][world.maplist[z][on_map].tilemap[y-1][x].replace.tile_pos[0]],(0,0))
  724. if time.minute%2 == 0:
  725. hs.blit(gra_files.gdic['edge']['n1'],(0,0))
  726. else:
  727. hs.blit(gra_files.gdic['edge']['n2'],(0,0))
  728. hs.set_colorkey((255,255,255),pygame.RLEACCEL)
  729. hs = hs.convert_alpha()
  730. s.blit(hs,(0,0))
  731. if mgs == 'soil' or mgs == 'low_liquid':
  732. hs = pygame.Surface((32,32))
  733. if world.maplist[z][on_map].tilemap[y+1][x].replace == None:
  734. hs.blit(gra_files.gdic['tile32'][world.maplist[z][on_map].tilemap[y+1][x].tile_pos[1]][world.maplist[z][on_map].tilemap[y+1][x].tile_pos[0]],(0,0))
  735. else:
  736. hs.blit(gra_files.gdic['tile32'][world.maplist[z][on_map].tilemap[y+1][x].replace.tile_pos[1]][world.maplist[z][on_map].tilemap[y+1][x].replace.tile_pos[0]],(0,0))
  737. if time.minute%2 == 0:
  738. hs.blit(gra_files.gdic['edge']['s1'],(0,0))
  739. else:
  740. hs.blit(gra_files.gdic['edge']['s2'],(0,0))
  741. hs.set_colorkey((255,255,255),pygame.RLEACCEL)
  742. hs = hs.convert_alpha()
  743. s.blit(hs,(0,0))
  744. if visible == False:
  745. s.blit(gra_files.gdic['display'][6],(0,0))
  746. if world.maplist[z][on_map].npcs[y][x] != 0:
  747. s.blit(self.draw_monster(x,y,z,on_map,visible),(0,0))
  748. return s
  749. def draw_monster(self,x,y,z,on_map,visible):
  750. s = pygame.Surface((32,32))
  751. s.fill((255,0,255))
  752. if visible == True:
  753. pos = world.maplist[z][on_map].npcs[y][x].sprite_pos
  754. s.blit(gra_files.gdic['monster'][pos[1]][pos[0]],(0,0))
  755. if not 'hover' in world.maplist[z][on_map].npcs[y][x].properties:
  756. if world.maplist[z][on_map].tilemap[y][x].move_group == 'low_liquid':
  757. help_s = pygame.Surface((32,5))
  758. help_s.fill((255,0,255))
  759. s.blit(help_s,(0,27))
  760. elif world.maplist[z][on_map].tilemap[y][x].move_group == 'swim':
  761. help_s = pygame.Surface((32,13))
  762. help_s.fill((255,0,255))
  763. s.blit(help_s,(0,19))
  764. if '-skill' in world.maplist[z][on_map].npcs[y][x].properties:
  765. s.blit(gra_files.gdic['display'][73],(0,0))
  766. elif 'blind' in world.maplist[z][on_map].npcs[y][x].properties:
  767. s.blit(gra_files.gdic['display'][74],(0,0))
  768. if world.maplist[z][on_map].npcs[y][x].quest_state != 'None':
  769. s.blit(gra_files.gdic['display'][59],(0,0))
  770. if world.maplist[z][on_map].npcs[y][x].move_border == 10:
  771. None
  772. elif world.maplist[z][on_map].npcs[y][x].AI_style == 'ignore':
  773. s.blit(gra_files.gdic['display'][28],(0,0))
  774. if not ('pet0' in world.maplist[z][on_map].npcs[y][x].properties or 'pet1' in world.maplist[z][on_map].npcs[y][x].properties or 'pet2' in world.maplist[z][on_map].npcs[y][x].properties or 'npc' in world.maplist[z][on_map].npcs[y][x].properties):
  775. lvl = str(world.maplist[z][on_map].npcs[y][x].lvl)
  776. if len(lvl) == 1:
  777. lvl = '0'+lvl
  778. elif len(lvl) > 2:
  779. lvl = lvl[0]+'+'
  780. s.blit(gra_files.gdic['num'][lvl[0]],(0,6))
  781. s.blit(gra_files.gdic['num'][lvl[1]],(0,14))
  782. elif 'npc' in world.maplist[z][on_map].npcs[y][x].properties:
  783. s.blit(gra_files.gdic['display'][76],(0,6))
  784. else:
  785. s.blit(gra_files.gdic['display'][72],(0,6))
  786. elif world.maplist[z][on_map].npcs[y][x].AI_style == 'flee':
  787. s.blit(gra_files.gdic['display'][29],(0,0))
  788. lvl = str(world.maplist[z][on_map].npcs[y][x].lvl)
  789. if len(lvl) == 1:
  790. lvl = '0'+lvl
  791. elif len(lvl) > 2:
  792. lvl = lvl[0]+'+'
  793. s.blit(gra_files.gdic['num'][lvl[0]],(0,6))
  794. s.blit(gra_files.gdic['num'][lvl[1]],(0,14))
  795. elif world.maplist[z][on_map].npcs[y][x].AI_style == 'company':
  796. s.blit(gra_files.gdic['display'][71],(0,0))
  797. help_sur_0 = pygame.Surface((26,3))
  798. help_sur_0.fill((48,48,48))
  799. s.blit(help_sur_0,(3,29))
  800. help_sur_1 = pygame.Surface((24,1))
  801. help_sur_1.fill((89,0,0))
  802. s.blit(help_sur_1,(4,30))
  803. hs2_length = (24*player.pet_lp)/world.maplist[z][on_map].npcs[y][x].basic_attribute.max_lp
  804. help_sur_2 = pygame.Surface((hs2_length,1))
  805. help_sur_2.fill((0,255,0))
  806. s.blit(help_sur_2,(4,30))
  807. else:
  808. s.blit(gra_files.gdic['display'][30],(0,0))
  809. lvl = str(world.maplist[z][on_map].npcs[y][x].lvl)
  810. if len(lvl) == 1:
  811. lvl = '0'+lvl
  812. elif len(lvl) > 2:
  813. lvl = lvl[0]+'+'
  814. s.blit(gra_files.gdic['num'][lvl[0]],(0,6))
  815. s.blit(gra_files.gdic['num'][lvl[1]],(0,14))
  816. if world.maplist[z][on_map].npcs[y][x].move_border > 10:
  817. s.blit(gra_files.gdic['display'][69],(0,0))
  818. else:
  819. if world.maplist[z][on_map].npcs[y][x].techID == ml.mlist['special'][0].techID or world.maplist[z][on_map].npcs[y][x].techID == ml.mlist['special'][1].techID or world.maplist[z][on_map].npcs[y][x].techID == ml.mlist['special'][3].techID or world.maplist[z][on_map].npcs[y][x].name == 'cage':
  820. pos = world.maplist[z][on_map].npcs[y][x].sprite_pos
  821. s.blit(gra_files.gdic['monster'][pos[1]][pos[0]],(0,0))
  822. else:
  823. coin = random.randint(0,1)
  824. if coin == 1:
  825. s.blit(gra_files.gdic['display'][7],(0,0))
  826. else:
  827. s.blit(gra_files.gdic['display'][6],(0,0))
  828. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  829. return s
  830. def generate_light_effect(self):
  831. if player.buffs.get_buff('berserk') > 0:
  832. y = 3
  833. elif player.buffs.get_buff('night vision') > 0:
  834. y = 2
  835. elif player.pos[2] > 0:
  836. y = 1
  837. else:
  838. y= 0
  839. x = time.hour
  840. if player.buffs.get_buff('berserk') > 0:
  841. alpha = 135
  842. elif player.buffs.get_buff('night vision') > 0:
  843. alpha = 60
  844. elif player.pos[2] == 0:
  845. if time.hour == 12:
  846. alpha = 0
  847. elif time.hour < 12:
  848. alpha = 60-(time.hour*5)
  849. elif time.hour > 12:
  850. alpha = 0+((time.hour-12)*5)
  851. else:
  852. alpha = 135
  853. light_color = gra_files.gdic['lightmap'].get_at((x,y))
  854. s = pygame.Surface((640,360))
  855. s.fill(light_color)
  856. if player.buffs.get_buff('light') > 0 and player.buffs.get_buff('berserk') == 0:
  857. pygame.draw.circle(s,(255,0,255),[254,197],120,0)
  858. help_tile = pygame.Surface((32,32))
  859. help_tile.fill(light_color)
  860. fov = world.maplist[player.pos[2]][player.on_map].check_fov(player.pos[0],player.pos[1],6)
  861. for y in range(0,len(fov)-1):
  862. for x in range(0,len(fov[y])-1):
  863. if fov[y][x] == 0:
  864. s.blit(help_tile,(x*32,y*32))
  865. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  866. s.set_alpha(alpha)
  867. return s
  868. def render(self,mes_num, simulate = False, photo = False):
  869. radius = 6
  870. if player.pos[2] > 0:
  871. radius = 2
  872. elif player.pos[2] == 0:
  873. if time.hour > 22 or time.hour < 4:
  874. radius = 2
  875. elif time.hour > 21 or time.hour < 5:
  876. radius = 3
  877. elif time.hour > 20 or time.hour < 6:
  878. radius = 4
  879. elif time.hour > 19 or time.hour < 7:
  880. radius = 5
  881. if player.buffs.get_buff('light') > 0 or player.buffs.get_buff('night vision'):
  882. radius = 6
  883. if player.buffs.get_buff('blind') > 0:
  884. radius = 0
  885. s = pygame.Surface((640,360))
  886. test = message.sget()
  887. s.fill((48,48,48)) #paint it grey(to clear the screen)
  888. start_pos_x = 240 #the center of the main map view
  889. start_pos_y = 180
  890. ymin = player.pos[1]-6
  891. ymax = player.pos[1]+6
  892. xmin = player.pos[0]-8
  893. xmax = player.pos[0]+7
  894. ry = 0
  895. fow = world.maplist[player.pos[2]][player.on_map].check_fov(player.pos[0],player.pos[1],radius)
  896. for y in range(ymin,ymax):
  897. rx = 0
  898. for x in range(xmin,xmax):
  899. s.blit(screen.draw_tile(player.on_map,x,y,player.pos[2],fow[ry][rx]),(rx*32,ry*32))
  900. if x == player.pos[0] and y == player.pos[1]:
  901. s.blit(screen.draw_player(),(rx*32,ry*32))
  902. player_pos_help = (x,y)
  903. rx+=1
  904. ry+=1
  905. s.blit(self.render_hits(),(0,0))
  906. s.blit(screen.generate_light_effect(),(0,0))
  907. if photo == True:
  908. if low_res == False:
  909. photo_help = pygame.Surface((480,360))
  910. photo_help.blit(s,(0,0))
  911. s = photo_help
  912. else:
  913. photo_help = pygame.Surface((320,240))
  914. photo_help.blit(s,(0,0))
  915. s = photo_help
  916. return s
  917. if self.fire_mode == 0:
  918. if (player.lp*100)/player.attribute.max_lp>20 and (player.attribute.hunger*100)/player.attribute.hunger_max>10 and (player.attribute.thirst*100)/player.attribute.thirst_max>10 and (player.attribute.tiredness*100)/player.attribute.tiredness_max>10:
  919. s.blit(gra_files.gdic['display'][0],(0,0)) #render gui
  920. else:
  921. s.blit(gra_files.gdic['display'][25],(0,0)) #render gui_warning
  922. elif self.fire_mode == 1:
  923. s.blit(gra_files.gdic['display'][10],(0,0))
  924. s.blit(gra_files.gdic['display'][41],(start_pos_x+((player_pos_help[0]-player.pos[0])*32)-16,start_pos_y+((player_pos_help[1]-player.pos[1])*32)-16))
  925. else:
  926. if (player.lp*100)/player.attribute.max_lp>20 and (player.attribute.hunger*100)/player.attribute.hunger_max>10 and (player.attribute.thirst*100)/player.attribute.thirst_max>10 and (player.attribute.tiredness*100)/player.attribute.tiredness_max>10:
  927. s.blit(gra_files.gdic['display'][0],(0,0)) #render gui
  928. else:
  929. s.blit(gra_files.gdic['display'][25],(0,0)) #render gui_warning
  930. s.blit(gra_files.gdic['display'][68],(start_pos_x+((player_pos_help[0]-player.pos[0])*32)-16,start_pos_y+((player_pos_help[1]-player.pos[1])*32)-16))
  931. #render tool info
  932. #1. Axe
  933. if player.inventory.wearing['Axe'] == player.inventory.nothing:
  934. s.blit(gra_files.gdic['display'][44],(0,39))
  935. else:
  936. s.blit(gra_files.gdic['display'][46],(0,39))
  937. axestring = 'WEAPONS_' + player.inventory.wearing['Axe'].material + '_' + player.inventory.wearing['Axe'].classe
  938. s.blit(gra_files.gdic['char'][axestring],(0,39))
  939. s.blit(gra_files.gdic['display'][47],(0,39))
  940. axe_state = (15*player.inventory.wearing['Axe'].state)/100
  941. help_sur = pygame.Surface((axe_state,1))
  942. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  943. s.blit(help_sur,(10,67))
  944. #2. Pickaxe
  945. if player.inventory.wearing['Pickaxe'] == player.inventory.nothing:
  946. s.blit(gra_files.gdic['display'][45],(16,39))
  947. else:
  948. s.blit(gra_files.gdic['display'][46],(16,39))
  949. pickaxestring = 'WEAPONS_' + player.inventory.wearing['Pickaxe'].material + '_' + player.inventory.wearing['Pickaxe'].classe
  950. s.blit(gra_files.gdic['char'][pickaxestring],(16,39))
  951. s.blit(gra_files.gdic['display'][47],(16,39))
  952. pickaxe_state = (15*player.inventory.wearing['Pickaxe'].state)/100
  953. help_sur = pygame.Surface((pickaxe_state,1))
  954. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  955. s.blit(help_sur,(26,67))
  956. #3. Melee weapon
  957. if player.inventory.wearing['Hold(R)'] == player.inventory.nothing:
  958. s.blit(gra_files.gdic['display'][52],(32,39))
  959. else:
  960. s.blit(gra_files.gdic['display'][46],(32,39))
  961. melee_string = 'WEAPONS_' + player.inventory.wearing['Hold(R)'].material + '_' + player.inventory.wearing['Hold(R)'].classe
  962. if player.inventory.wearing['Hold(R)'].classe != 'spear':
  963. s.blit(gra_files.gdic['char'][melee_string],(32,39))
  964. else:
  965. h_sur = pygame.Surface((32,19))
  966. h_sur.fill((255,0,255))
  967. h_sur.blit(gra_files.gdic['char'][melee_string],(0,0))
  968. h_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  969. h_sur = h_sur.convert_alpha()
  970. s.blit(h_sur,(39,48))
  971. s.blit(gra_files.gdic['display'][47],(32,39))
  972. melee_state = (15*player.inventory.wearing['Hold(R)'].state)/100
  973. help_sur = pygame.Surface((melee_state,1))
  974. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  975. s.blit(help_sur,(42,67))
  976. #4. Magic weapon
  977. if player.inventory.wearing['Hold(L)'] == player.inventory.nothing:
  978. s.blit(gra_files.gdic['display'][53],(48,39))
  979. else:
  980. s.blit(gra_files.gdic['display'][46],(48,39))
  981. magic_string = 'WEAPONS_' + player.inventory.wearing['Hold(L)'].material + '_' + player.inventory.wearing['Hold(L)'].classe
  982. if player.inventory.wearing['Hold(L)'].classe != 'rune staff':
  983. s.blit(gra_files.gdic['char'][magic_string],(42,39))
  984. else:
  985. h_sur = pygame.Surface((32,19))
  986. h_sur.fill((255,0,255))
  987. h_sur.blit(gra_files.gdic['char'][magic_string],(0,0))
  988. h_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  989. h_sur = h_sur.convert_alpha()
  990. s.blit(h_sur,(42,48))
  991. s.blit(gra_files.gdic['display'][47],(48,39))
  992. magic_state = (15*player.inventory.wearing['Hold(L)'].state)/100
  993. help_sur = pygame.Surface((magic_state,1))
  994. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  995. s.blit(help_sur,(58,67))
  996. #5. Necklace
  997. if player.inventory.wearing['Neck'] == player.inventory.nothing:
  998. s.blit(gra_files.gdic['display'][40],(64,39))
  999. else:
  1000. s.blit(gra_files.gdic['display'][46],(64,39))
  1001. necklacestring = 'WEAPONS_' + player.inventory.wearing['Neck'].material + '_' + player.inventory.wearing['Neck'].classe
  1002. s.blit(gra_files.gdic['char'][necklacestring],(64,39))
  1003. s.blit(gra_files.gdic['display'][47],(64,39))
  1004. necklace_state = (15*player.inventory.wearing['Neck'].state)/100
  1005. help_sur = pygame.Surface((necklace_state,1))
  1006. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  1007. s.blit(help_sur,(74,67))
  1008. #6. Helmet
  1009. if player.inventory.wearing['Head'] == player.inventory.nothing:
  1010. s.blit(gra_files.gdic['display'][54],(0,54))
  1011. else:
  1012. s.blit(gra_files.gdic['display'][46],(0,54))
  1013. helmet_string = player.gender + '_' + player.inventory.wearing['Head'].material + '_' + player.inventory.wearing['Head'].classe
  1014. h_sur = pygame.Surface((32,32))
  1015. h_sur.fill((255,0,255))
  1016. h_sur.blit(gra_files.gdic['char'][helmet_string],(0,0))
  1017. pygame.draw.rect(h_sur,(255,0,255),(0,0,10,32),0)
  1018. pygame.draw.rect(h_sur,(255,0,255),(0,0,32,4),0)
  1019. pygame.draw.rect(h_sur,(255,0,255),(25,0,7,32),0)
  1020. h_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  1021. h_sur = h_sur.convert_alpha()
  1022. s.blit(h_sur,(0,65))
  1023. s.blit(gra_files.gdic['display'][47],(0,54))
  1024. helmet_state = (15*player.inventory.wearing['Head'].state)/100
  1025. help_sur = pygame.Surface((helmet_state,1))
  1026. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  1027. s.blit(help_sur,(10,82))
  1028. #7. Armor
  1029. if player.inventory.wearing['Body'] == player.inventory.nothing:
  1030. s.blit(gra_files.gdic['display'][55],(16,54))
  1031. else:
  1032. s.blit(gra_files.gdic['display'][46],(16,54))
  1033. armor_string = player.gender + '_' + player.inventory.wearing['Body'].material + '_' + player.inventory.wearing['Body'].classe
  1034. h_sur = pygame.Surface((32,32))
  1035. h_sur.fill((255,0,255))
  1036. h_sur.blit(gra_files.gdic['char'][armor_string],(0,0))
  1037. pygame.draw.rect(h_sur,(255,0,255),(0,0,10,32),0)
  1038. pygame.draw.rect(h_sur,(255,0,255),(25,0,7,32),0)
  1039. h_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  1040. h_sur = h_sur.convert_alpha()
  1041. s.blit(h_sur,(16,55))
  1042. s.blit(gra_files.gdic['display'][47],(16,54))
  1043. armor_state = (15*player.inventory.wearing['Body'].state)/100
  1044. help_sur = pygame.Surface((armor_state,1))
  1045. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  1046. s.blit(help_sur,(26,82))
  1047. #8. Cuisse
  1048. if player.inventory.wearing['Legs'] == player.inventory.nothing:
  1049. s.blit(gra_files.gdic['display'][56],(32,54))
  1050. else:
  1051. s.blit(gra_files.gdic['display'][46],(32,54))
  1052. cuisse_string = player.gender + '_' + player.inventory.wearing['Legs'].material + '_' + player.inventory.wearing['Legs'].classe
  1053. s.blit(gra_files.gdic['char'][cuisse_string],(32,50))
  1054. s.blit(gra_files.gdic['display'][47],(32,54))
  1055. cuisse_state = (15*player.inventory.wearing['Legs'].state)/100
  1056. help_sur = pygame.Surface((cuisse_state,1))
  1057. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  1058. s.blit(help_sur,(42,82))
  1059. #9. Shoes
  1060. if player.inventory.wearing['Feet'] == player.inventory.nothing:
  1061. s.blit(gra_files.gdic['display'][57],(48,54))
  1062. else:
  1063. s.blit(gra_files.gdic['display'][46],(48,54))
  1064. shoes_string = player.gender + '_' + player.inventory.wearing['Feet'].material + '_' + player.inventory.wearing['Feet'].classe
  1065. s.blit(gra_files.gdic['char'][shoes_string],(49,46))
  1066. s.blit(gra_files.gdic['display'][47],(48,54))
  1067. shoes_state = (15*player.inventory.wearing['Feet'].state)/100
  1068. help_sur = pygame.Surface((shoes_state,1))
  1069. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  1070. s.blit(help_sur,(58,82))
  1071. #10. Ring
  1072. if player.inventory.wearing['Hand'] == player.inventory.nothing:
  1073. s.blit(gra_files.gdic['display'][39],(64,54))
  1074. else:
  1075. s.blit(gra_files.gdic['display'][46],(64,54))
  1076. ring_string = 'WEAPONS_' + player.inventory.wearing['Hand'].material + '_' + player.inventory.wearing['Hand'].classe
  1077. s.blit(gra_files.gdic['char'][ring_string],(64,54))
  1078. s.blit(gra_files.gdic['display'][47],(64,54))
  1079. ring_state = (15*player.inventory.wearing['Hand'].state)/100
  1080. help_sur = pygame.Surface((ring_state,1))
  1081. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  1082. s.blit(help_sur,(74,82))
  1083. #render icons
  1084. #1. Use
  1085. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]][player.pos[0]].use_group == 'None' and world.maplist[player.pos[2]][player.on_map].containers[player.pos[1]][player.pos[0]] == 0:
  1086. s.blit(gra_files.gdic['display'][32],(0,161))
  1087. s.blit(gra_files.gdic['display'][34],(0,161))
  1088. else:
  1089. s.blit(gra_files.gdic['display'][31],(0,161))
  1090. s.blit(gra_files.gdic['display'][33],(0,161))
  1091. use_string = '['+key_name['e']+']action'
  1092. use_image1 = self.font.render(use_string,1,(0,0,0))
  1093. use_image2 = self.font.render(use_string,1,(255,255,255))
  1094. s.blit(use_image1,(36,173))
  1095. s.blit(use_image2,(34,173))
  1096. #2. Fire
  1097. if player.inventory.wearing['Hold(L)'] == player.inventory.nothing or player.mp < 2:
  1098. s.blit(gra_files.gdic['display'][32],(0,129))
  1099. s.blit(gra_files.gdic['display'][36],(0,129))
  1100. else:
  1101. s.blit(gra_files.gdic['display'][31],(0,129))
  1102. s.blit(gra_files.gdic['display'][35],(0,129))
  1103. if self.fire_mode == False:
  1104. fire_string = '['+key_name['f']+']fire'
  1105. else:
  1106. fire_string = '['+key_name['x']+']cancel'
  1107. fire_image1 = self.font.render(fire_string,1,(0,0,0))
  1108. fire_image2 = self.font.render(fire_string,1,(255,255,255))
  1109. s.blit(fire_image1,(36,141))
  1110. s.blit(fire_image2,(34,141))
  1111. #4.Focus
  1112. s.blit(gra_files.gdic['display'][32],(0,97))#65
  1113. try:
  1114. focus_state = (32*player.mp/player.attribute.max_mp)
  1115. except:
  1116. focus_state = 1
  1117. help_sur = pygame.Surface((focus_state,32))
  1118. help_sur.fill((255,0,255))
  1119. help_sur.blit(gra_files.gdic['display'][31],(0,0))
  1120. help_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  1121. help_sur = help_sur.convert_alpha()
  1122. s.blit(help_sur,(0,97))
  1123. if player.mp < player.attribute.max_mp:
  1124. s.blit(gra_files.gdic['display'][38],(0,97))
  1125. focus_string = 'unfocused'
  1126. else:
  1127. s.blit(gra_files.gdic['display'][37],(0,97))
  1128. focus_string = 'focused'
  1129. focus_image1 = self.font.render(focus_string,1,(0,0,0))
  1130. focus_image2 = self.font.render(focus_string,1,(255,255,255))
  1131. s.blit(focus_image1,(36,109))#77
  1132. s.blit(focus_image2,(34,109))
  1133. # render messages
  1134. help_sur = pygame.Surface((480,60))
  1135. help_sur.fill((48,48,48))
  1136. help_sur.set_alpha(120)
  1137. mes_pos_y = 345
  1138. s.blit(help_sur,(0,300))
  1139. mlist = test
  1140. for c in range(0,5):
  1141. if c > 2:
  1142. color = (160,160,160)
  1143. elif c > 0:
  1144. color = (206,206,206)
  1145. else:
  1146. color = (255,255,255)
  1147. shadow_image = self.font.render(mlist[c],1,(0,0,0))
  1148. text_image = self.font.render(mlist[c],1,color)
  1149. s.blit(shadow_image,(2,mes_pos_y-(c*10)))
  1150. s.blit(text_image,(0,mes_pos_y-(c*10)))
  1151. #render lvl info
  1152. lvl_string = str(player.lvl)
  1153. if len(lvl_string) == 1:
  1154. lvl_string = '0'+lvl_string
  1155. lvl_image = self.font.render(lvl_string,1,(255,255,255))
  1156. s.blit(lvl_image,(153,48))
  1157. bar_length = 1 + ((319/100)*player.xp)
  1158. xp_surface = pygame.Surface((bar_length,64))
  1159. xp_surface.fill((255,0,255))
  1160. xp_surface.blit(gra_files.gdic['display'][19],(0,0))
  1161. xp_surface.set_colorkey((255,0,255),pygame.RLEACCEL)
  1162. xp_surface = xp_surface.convert_alpha()
  1163. s.blit(xp_surface,(0,0))
  1164. if game_options.mousepad == 1:
  1165. if self.fire_mode == 0:
  1166. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  1167. else:
  1168. s.blit(gra_files.gdic['display'][9],(480,0))
  1169. else:
  1170. s_help = pygame.Surface((160,360))
  1171. s_help.fill((48,48,48))
  1172. s.blit(s_help,(480,0))
  1173. #render buffs
  1174. buffs = player.buffs.sget()
  1175. if low_res == False:
  1176. posx = 388
  1177. posy = 10
  1178. else:
  1179. posx = 228
  1180. posy = 75
  1181. for i in buffs:
  1182. if i != ' ':
  1183. buff_shadow = self.font.render(i,1,(0,0,0))
  1184. s.blit(buff_shadow,(posx+2,posy))
  1185. buff_image = self.font.render(i,1,(200,200,200))
  1186. s.blit(buff_image,(posx,posy))
  1187. else:
  1188. None
  1189. posy += 20
  1190. #render date
  1191. date_string = time.sget()
  1192. posx = 235
  1193. posy = 10
  1194. date_image = self.font.render(date_string[0],1,(0,0,0))
  1195. s.blit(date_image,(posx,posy))
  1196. posy = 20
  1197. time_image = self.font.render(date_string[1],1,(0,0,0))
  1198. s.blit(time_image,(posx,posy))
  1199. #render player info
  1200. #lp
  1201. lp_string = str(player.lp) + '/' + str(player.attribute.max_lp)
  1202. posx = 13
  1203. posy = 12
  1204. if player.lp < 4:
  1205. lp_image = self.font.render(lp_string,1,(200,0,0))
  1206. else:
  1207. lp_image = self.font.render(lp_string,1,(0,0,0))
  1208. s.blit(lp_image,(posx,posy))
  1209. #hunger
  1210. hunger_percent = int((100 * player.attribute.hunger) / player.attribute.hunger_max)
  1211. hunger_string = str(hunger_percent) + '%'
  1212. posx = 75
  1213. posy = 12
  1214. if hunger_percent < 11:
  1215. hunger_image = self.font.render(hunger_string,1,(200,0,0))
  1216. else:
  1217. hunger_image = self.font.render(hunger_string,1,(0,0,0))
  1218. s.blit(hunger_image,(posx,posy))
  1219. #trirst
  1220. thirst_percent = int((100 * player.attribute.thirst) / player.attribute.thirst_max)
  1221. thirst_string = str(thirst_percent) + '%'
  1222. posx = 125
  1223. posy = 12
  1224. if thirst_percent < 11:
  1225. thirst_image = self.font.render(thirst_string,1,(200,0,0))
  1226. else:
  1227. thirst_image = self.font.render(thirst_string,1,(0,0,0))
  1228. s.blit(thirst_image,(posx,posy))
  1229. #tiredness
  1230. tiredness_percent = int((100 * player.attribute.tiredness) / player.attribute.tiredness_max)
  1231. tiredness_string = str(tiredness_percent) + '%'
  1232. posx = 180
  1233. posy = 12
  1234. if tiredness_percent < 11:
  1235. tiredness_image = self.font.render(tiredness_string,1,(200,0,0))
  1236. else:
  1237. tiredness_image = self.font.render(tiredness_string,1,(0,0,0))
  1238. s.blit(tiredness_image,(posx,posy))
  1239. if game_options.mousepad == 0:
  1240. s_help = pygame.Surface((640,360))
  1241. s_help.fill((48,48,48))
  1242. s_help.blit(s,(80,0))
  1243. s = s_help
  1244. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1245. self.screen.blit(s,(0,0))
  1246. if simulate == False:
  1247. pygame.display.flip()
  1248. else:
  1249. return s
  1250. if test[1] == '~*~':
  1251. return True
  1252. else:
  1253. return False
  1254. def render_load(self,num,progress=None):
  1255. s = pygame.Surface((640,360))
  1256. s.fill((48,48,48)) #paint it grey(to clear the screen)
  1257. if num == 0:
  1258. string = 'Looking for saved data... '
  1259. elif num == 1:
  1260. string = 'Loading world data...'
  1261. elif num == 2:
  1262. string = 'Nothing found...'
  1263. elif num == 3:
  1264. string = 'Generate overworld...'
  1265. elif num == 4:
  1266. string = 'Generate caves...'
  1267. elif num == 5:
  1268. string = 'Saving...'
  1269. elif num == 6:
  1270. string = 'Loading time data...'
  1271. elif num == 7:
  1272. string = 'Loading player data...'
  1273. elif num == 8:
  1274. string = 'Set time...'
  1275. elif num == 9:
  1276. string = 'Generate player...'
  1277. elif num == 10:
  1278. string = 'Making time related changes...'
  1279. elif num == 11:
  1280. string = 'Something has gone wrong...'
  1281. elif num == 12:
  1282. string = 'Zzzzzzzzzz'
  1283. elif num == 13:
  1284. string = 'Generate deus ex machina...'
  1285. elif num == 14:
  1286. string = 'Loading deus ex machina...'
  1287. elif num == 15:
  1288. string = 'Generate grot...'
  1289. elif num == 16:
  1290. string = 'Generate elfish fortress...'
  1291. elif num == 17:
  1292. string = 'Generate orcish mines...'
  1293. elif num == 18:
  1294. string = 'Generate desert...'
  1295. elif num == 19:
  1296. string = 'Initialize level...'
  1297. elif num == 20:
  1298. string = 'Please use run.py/run.exe'
  1299. ######add more here
  1300. if low_res == False:
  1301. posx = 150
  1302. posy = 200
  1303. else:
  1304. posx=50
  1305. posy= 100
  1306. image = self.font.render(string,1,(255,255,255))
  1307. s.blit(image,(posx,posy))
  1308. if progress != None:
  1309. s.blit(gra_files.gdic['display'][20],(posx-50,posy+20))
  1310. help_sur = pygame.Surface((((progress*320)/100),12))
  1311. help_sur.fill((255,0,255))
  1312. help_sur.blit(gra_files.gdic['display'][21],(0,0))
  1313. help_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  1314. help_sur = help_sur.convert_alpha()
  1315. s.blit(help_sur,(posx-50,posy+20))
  1316. if low_res == False:
  1317. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1318. self.screen.blit(s,(0,0))
  1319. pygame.display.flip()
  1320. def render_built(self,xmin,xmax,ymin,ymax,style):
  1321. start_pos_x = 256 #the center of the main map view
  1322. start_pos_y = 192
  1323. price = 0
  1324. bg = self.render(0, True)
  1325. s = pygame.Surface((640,360))
  1326. s.fill((255,0,255))
  1327. if style == 'Room':
  1328. build_total = True
  1329. for y in range (-ymin,ymax+1):
  1330. for x in range (-xmin,xmax+1):
  1331. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].move_group == 'soil' and world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].damage == False and world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].civilisation == False and world.maplist[player.pos[2]][player.on_map].npcs[player.pos[1]+y][player.pos[0]+x] == 0:
  1332. built_here = 1
  1333. price += 2
  1334. elif world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].civilisation == True:
  1335. built_here = 2
  1336. price += 1
  1337. else:
  1338. built_here = 0
  1339. if world.maplist[player.pos[2]][player.on_map].npcs[player.pos[1]+y][player.pos[0]+x] != 0:
  1340. built_here = 0
  1341. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].build_here == False:
  1342. built_here = 0
  1343. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].build_here == False:
  1344. if built_here == 1:
  1345. price -= 2
  1346. elif built_here == 2:
  1347. price -= 1
  1348. built_here = 0
  1349. if built_here == 0:
  1350. build_total = False
  1351. if build_total == False:
  1352. price = 0
  1353. for y in range (-ymin,ymax+1):
  1354. for x in range (-xmin,xmax+1):
  1355. if build_total != 0:
  1356. if x == xmax or x == -xmin or y == ymax or y == -ymin:
  1357. if x == xmax or x == -xmin:
  1358. if built_here == 1:
  1359. s.blit(gra_files.gdic['built'][1],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_true here
  1360. elif built_here == 2:
  1361. s.blit(gra_files.gdic['built'][6],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_over here
  1362. elif y == ymax or y == -ymin:
  1363. if built_here == 1:
  1364. s.blit(gra_files.gdic['built'][1],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_true here
  1365. elif built_here == 2:
  1366. s.blit(gra_files.gdic['built'][6],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_over here
  1367. else:
  1368. if built_here == 1:
  1369. s.blit(gra_files.gdic['built'][5],(start_pos_x+(x*32),start_pos_y+(y*32))) #floor_true here
  1370. elif built_here == 2:
  1371. s.blit(gra_files.gdic['built'][7],(start_pos_x+(x*32),start_pos_y+(y*32))) #floor_over
  1372. else:
  1373. if x == xmax or x == -xmin or y == ymax or y == -ymin:
  1374. if x == xmax or x == -xmin:
  1375. s.blit(gra_files.gdic['built'][0],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_false here
  1376. elif y == ymax or y == -ymin:
  1377. s.blit(gra_files.gdic['built'][0],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_false here
  1378. else:
  1379. s.blit(gra_files.gdic['built'][4],(start_pos_x+(x*32),start_pos_y+(y*32))) #floor_false here
  1380. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1381. # render mode name
  1382. name = '~Build Room~'
  1383. name_image = self.font.render(name,1,(255,255,255))
  1384. posx = 0
  1385. posy = 0
  1386. s.blit(name_image,(posx,posy))
  1387. # render wood needed
  1388. wood_need = int(price/2)
  1389. if wood_need == 0 and price != 0:
  1390. wood_need = 1
  1391. wood_string = 'Wood: ' + str(wood_need) + '(' + str(player.inventory.materials.wood) + ')'
  1392. posx = 0
  1393. posy = 15
  1394. if wood_need <= player.inventory.materials.wood:
  1395. wood_image = self.font.render(wood_string,1,(255,255,255))
  1396. else:
  1397. wood_image = self.font.render(wood_string,1,(200,0,0))
  1398. s.blit(wood_image,(posx,posy))
  1399. # render stone needed
  1400. stone_need = int(price/2)
  1401. if stone_need == 0 and price != 0:
  1402. stone_need = 1
  1403. stone_string = 'Stone: ' + str(stone_need) + '(' + str(player.inventory.materials.stone) + ')'
  1404. posx = 160
  1405. posy = 15
  1406. if stone_need <= player.inventory.materials.stone:
  1407. stone_image = self.font.render(stone_string,1,(255,255,255))
  1408. else:
  1409. stone_image = self.font.render(stone_string,1,(200,0,0))
  1410. s.blit(stone_image,(posx,posy))
  1411. # render info line
  1412. info_string_0 = '['+key_name['wasd']+']change Size'
  1413. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']BUILT!'
  1414. posx = 0
  1415. posy = 30
  1416. info_image = self.font.render(info_string_0,1,(255,255,255))
  1417. s.blit(info_image,(posx,posy))
  1418. posx = 0
  1419. posy = 40
  1420. info_image = self.font.render(info_string_1,1,(255,255,255))
  1421. s.blit(info_image,(posx,posy))
  1422. elif style == 'Doorway':
  1423. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].move_group == 'solid' and world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].damage == False and world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].civilisation == True and world.maplist[player.pos[2]][player.on_map].npcs[player.pos[1]+ymin][player.pos[0]+xmin] == 0:
  1424. built_here = 1
  1425. price += 2
  1426. else:
  1427. built_here = 0
  1428. if world.maplist[player.pos[2]][player.on_map].npcs[player.pos[1]+ymin][player.pos[0]+xmin] != 0:
  1429. built_here = False
  1430. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].build_here == False:
  1431. if built_here == 1:
  1432. price -= 2
  1433. elif built_here == 2:
  1434. price -= 1
  1435. built_here = 0
  1436. if built_here != 0:
  1437. if built_here == 1:
  1438. s.blit(gra_files.gdic['built'][3],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #door_true here
  1439. elif built_here == 2:
  1440. s.blit(gra_files.gdic['built'][8],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #door_over
  1441. else:
  1442. s.blit(gra_files.gdic['built'][2],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #door_false here
  1443. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1444. # render mode name
  1445. name = '~Built Doorway~'
  1446. name_image = self.font.render(name,1,(255,255,255))
  1447. posx = 0
  1448. posy = 0
  1449. s.blit(name_image,(posx,posy))
  1450. # render wood needed
  1451. wood_need = 0
  1452. wood_string = 'Wood: ' + str(wood_need) + '(' + str(player.inventory.materials.wood) + ')'
  1453. posx = 0
  1454. posy = 15
  1455. if wood_need <= player.inventory.materials.wood:
  1456. wood_image = self.font.render(wood_string,1,(255,255,255))
  1457. else:
  1458. wood_image = self.font.render(wood_string,1,(200,0,0))
  1459. s.blit(wood_image,(posx,posy))
  1460. # render stone needed
  1461. stone_need = 0
  1462. stone_string = 'Stone: ' + str(stone_need) + '(' + str(player.inventory.materials.stone) + ')'
  1463. posx = 160
  1464. posy = 15
  1465. if stone_need <= player.inventory.materials.stone:
  1466. stone_image = self.font.render(stone_string,1,(255,255,255))
  1467. else:
  1468. stone_image = self.font.render(stone_string,1,(200,0,0))
  1469. s.blit(stone_image,(posx,posy))
  1470. # render info line
  1471. info_string_0 = '['+key_name['wasd']+']change Position'
  1472. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']BUILT!'
  1473. posx = 0
  1474. posy = 30
  1475. info_image = self.font.render(info_string_0,1,(255,255,255))
  1476. s.blit(info_image,(posx,posy))
  1477. posx = 0
  1478. posy = 40
  1479. info_image = self.font.render(info_string_1,1,(255,255,255))
  1480. s.blit(info_image,(posx,posy))
  1481. elif style == 'Door':
  1482. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].move_group == 'soil' and world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].damage == False and world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].civilisation == False and world.maplist[player.pos[2]][player.on_map].npcs[player.pos[1]+ymin][player.pos[0]+xmin] == 0:
  1483. built_here = 1
  1484. price += 2
  1485. elif world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].civilisation == True:
  1486. built_here = 2
  1487. price += 1
  1488. else:
  1489. built_here = 0
  1490. if world.maplist[player.pos[2]][player.on_map].npcs[player.pos[1]+ymin][player.pos[0]+xmin] != 0:
  1491. built_here = False
  1492. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].build_here == False:
  1493. if built_here == 1:
  1494. price -= 2
  1495. elif built_here == 2:
  1496. price -= 1
  1497. built_here = 0
  1498. if built_here != 0:
  1499. if built_here == 1:
  1500. s.blit(gra_files.gdic['built'][3],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #door_true here
  1501. elif built_here == 2:
  1502. s.blit(gra_files.gdic['built'][8],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #door_over
  1503. else:
  1504. s.blit(gra_files.gdic['built'][2],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #door_false here
  1505. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1506. # render mode name
  1507. name = '~Built Door~'
  1508. name_image = self.font.render(name,1,(255,255,255))
  1509. posx = 0
  1510. posy = 0
  1511. s.blit(name_image,(posx,posy))
  1512. # render wood needed
  1513. wood_need = price
  1514. wood_string = 'Wood: ' + str(wood_need) + '(' + str(player.inventory.materials.wood) + ')'
  1515. posx = 0
  1516. posy = 15
  1517. if wood_need <= player.inventory.materials.wood:
  1518. wood_image = self.font.render(wood_string,1,(255,255,255))
  1519. else:
  1520. wood_image = self.font.render(wood_string,1,(200,0,0))
  1521. s.blit(wood_image,(posx,posy))
  1522. # render stone needed
  1523. stone_need = 0
  1524. stone_string = 'Stone: ' + str(stone_need) + '(' + str(player.inventory.materials.stone) + ')'
  1525. posx = 160
  1526. posy = 15
  1527. if stone_need <= player.inventory.materials.stone:
  1528. stone_image = self.font.render(stone_string,1,(255,255,255))
  1529. else:
  1530. stone_image = self.font.render(stone_string,1,(200,0,0))
  1531. s.blit(stone_image,(posx,posy))
  1532. # render info line
  1533. info_string_0 = '['+key_name['wasd']+']change Position'
  1534. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']BUILT!'
  1535. posx = 0
  1536. posy = 30
  1537. info_image = self.font.render(info_string_0,1,(255,255,255))
  1538. s.blit(info_image,(posx,posy))
  1539. posx = 0
  1540. posy = 40
  1541. info_image = self.font.render(info_string_1,1,(255,255,255))
  1542. s.blit(info_image,(posx,posy))
  1543. elif style == 'Stair up':
  1544. if player.pos[2] > 0:
  1545. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].replace == None and world.maplist[player.pos[2]-1][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].build_here == True and world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].build_here == True and world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].move_group == 'soil' and world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].damage == False:
  1546. build_here = 0
  1547. else:
  1548. build_here = 1
  1549. if build_here == 0:
  1550. s.blit(gra_files.gdic['built'][10],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #stair up true icon here
  1551. else:
  1552. s.blit(gra_files.gdic['built'][11],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #stair up false icon here
  1553. else:
  1554. s.blit(gra_files.gdic['built'][11],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #stair up false icon here
  1555. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1556. # render mode name
  1557. name = '~Built stair up~'
  1558. name_image = self.font.render(name,1,(255,255,255))
  1559. posx = 0
  1560. posy = 0
  1561. s.blit(name_image,(posx,posy))
  1562. # render wood needed
  1563. wood_need = 10
  1564. wood_string = 'Wood: ' + str(wood_need) + '(' + str(player.inventory.materials.wood) + ')'
  1565. posx = 0
  1566. posy = 15
  1567. if wood_need <= player.inventory.materials.wood:
  1568. wood_image = self.font.render(wood_string,1,(255,255,255))
  1569. else:
  1570. wood_image = self.font.render(wood_string,1,(200,0,0))
  1571. s.blit(wood_image,(posx,posy))
  1572. # render stone needed
  1573. stone_need = 40
  1574. stone_string = 'Stone: ' + str(stone_need) + '(' + str(player.inventory.materials.stone) + ')'
  1575. posx = 160
  1576. posy = 15
  1577. if stone_need <= player.inventory.materials.stone:
  1578. stone_image = self.font.render(stone_string,1,(255,255,255))
  1579. else:
  1580. stone_image = self.font.render(stone_string,1,(200,0,0))
  1581. s.blit(stone_image,(posx,posy))
  1582. # render info line
  1583. info_string_0 = '['+key_name['wasd']+']change Position'
  1584. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']BUILT!'
  1585. posx = 0
  1586. posy = 30
  1587. info_image = self.font.render(info_string_0,1,(255,255,255))
  1588. s.blit(info_image,(posx,posy))
  1589. posx = 0
  1590. posy = 40
  1591. info_image = self.font.render(info_string_1,1,(255,255,255))
  1592. s.blit(info_image,(posx,posy))
  1593. elif style == 'Stair down':
  1594. if player.pos[2] < 15:
  1595. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].replace == None and world.maplist[player.pos[2]+1][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].build_here == True and world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].build_here == True and world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].move_group == 'soil' and world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].damage == False:
  1596. build_here = 0
  1597. else:
  1598. build_here = 1
  1599. if build_here == 0:
  1600. s.blit(gra_files.gdic['built'][12],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #stair up true icon here
  1601. else:
  1602. s.blit(gra_files.gdic['built'][13],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #stair up false icon here
  1603. else:
  1604. s.blit(gra_files.gdic['built'][12],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #stair up false icon here
  1605. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1606. # render mode name
  1607. name = '~Built stair down~'
  1608. name_image = self.font.render(name,1,(255,255,255))
  1609. posx = 0
  1610. posy = 0
  1611. s.blit(name_image,(posx,posy))
  1612. # render wood needed
  1613. wood_need = 10
  1614. wood_string = 'Wood: ' + str(wood_need) + '(' + str(player.inventory.materials.wood) + ')'
  1615. posx = 0
  1616. posy = 15
  1617. if wood_need <= player.inventory.materials.wood:
  1618. wood_image = self.font.render(wood_string,1,(255,255,255))
  1619. else:
  1620. wood_image = self.font.render(wood_string,1,(200,0,0))
  1621. s.blit(wood_image,(posx,posy))
  1622. # render stone needed
  1623. if player.pos[2] > 0:
  1624. stone_need = 40
  1625. else:
  1626. stone_need = 15
  1627. stone_string = 'Stone: ' + str(stone_need) + '(' + str(player.inventory.materials.stone) + ')'
  1628. posx = 160
  1629. posy = 15
  1630. if stone_need <= player.inventory.materials.stone:
  1631. stone_image = self.font.render(stone_string,1,(255,255,255))
  1632. else:
  1633. stone_image = self.font.render(stone_string,1,(200,0,0))
  1634. s.blit(stone_image,(posx,posy))
  1635. # render info line
  1636. info_string_0 = '['+key_name['wasd']+']change Position'
  1637. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']BUILT!'
  1638. posx = 0
  1639. posy = 30
  1640. info_image = self.font.render(info_string_0,1,(255,255,255))
  1641. s.blit(info_image,(posx,posy))
  1642. posx = 0
  1643. posy = 40
  1644. info_image = self.font.render(info_string_1,1,(255,255,255))
  1645. s.blit(info_image,(posx,posy))
  1646. elif style == 'Agriculture':
  1647. for y in range (-ymin,ymax+1):
  1648. for x in range (-xmin,xmax+1):
  1649. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].move_group == 'soil' and world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].damage == False and world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].civilisation == False:
  1650. built_here = 1
  1651. price += 1
  1652. elif world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].civilisation == True:
  1653. built_here = 2
  1654. price += 1
  1655. else:
  1656. built_here = 0
  1657. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].build_here == False:
  1658. if built_here == 1:
  1659. price -= 2
  1660. elif built_here == 2:
  1661. price -= 1
  1662. built_here = 0
  1663. if built_here != 0:
  1664. if built_here == 1:
  1665. s.blit(gra_files.gdic['built'][15],(start_pos_x+(x*32),start_pos_y+(y*32))) #floor_true here
  1666. elif built_here == 2:
  1667. s.blit(gra_files.gdic['built'][16],(start_pos_x+(x*32),start_pos_y+(y*32))) #floor_over
  1668. else:
  1669. s.blit(gra_files.gdic['built'][14],(start_pos_x+(x*32),start_pos_y+(y*32))) #floor_false here
  1670. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1671. # render mode name
  1672. name = '~Build Agriculture~'
  1673. name_image = self.font.render(name,1,(255,255,255))
  1674. posx = 0
  1675. posy = 0
  1676. s.blit(name_image,(posx,posy))
  1677. # render seeds needed
  1678. seed_need = price
  1679. if seed_need == 0:
  1680. seed_need = 1
  1681. wood_need = seed_need
  1682. stone_need = 0
  1683. wood_string = 'Seeds: ' + str(seed_need) + '(' + str(player.inventory.materials.seeds) + ')'
  1684. posx = 120
  1685. posy = 15
  1686. if wood_need <= player.inventory.materials.seeds:
  1687. wood_image = self.font.render(wood_string,1,(255,255,255))
  1688. else:
  1689. wood_image = self.font.render(wood_string,1,(200,0,0))
  1690. s.blit(wood_image,(posx,posy))
  1691. # render info line
  1692. info_string_0 = '['+key_name['wasd']+']change Size'
  1693. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']BUILT!'
  1694. posx = 0
  1695. posy = 30
  1696. info_image = self.font.render(info_string_0,1,(255,255,255))
  1697. s.blit(info_image,(posx,posy))
  1698. posx = 0
  1699. posy = 40
  1700. info_image = self.font.render(info_string_1,1,(255,255,255))
  1701. s.blit(info_image,(posx,posy))
  1702. elif style == 'remove':
  1703. shape = world.maplist[player.pos[2]][player.on_map].float_building_shape(player.pos[0]+xmin,player.pos[1]+ymin)
  1704. for y in range(player.pos[1]-8,player.pos[1]+8):
  1705. for x in range(player.pos[0]-6,player.pos[0]+6):
  1706. rx = x-player.pos[0]
  1707. ry = y-player.pos[1]
  1708. if shape[y][x] == 1:
  1709. s.blit(gra_files.gdic['built'][9],(start_pos_x+(rx*32),start_pos_y+(ry*32))) #remove icon here
  1710. s.blit(gra_files.gdic['built'][19],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #remove icon here
  1711. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1712. # render mode name
  1713. name = '~Remove~'
  1714. name_image = self.font.render(name,1,(255,255,255))
  1715. posx = 0
  1716. posy = 0
  1717. s.blit(name_image,(posx,posy))
  1718. # render ---
  1719. wood_string = '---'
  1720. posx = 120
  1721. posy = 15
  1722. wood_image = self.font.render(wood_string,1,(255,255,255))
  1723. s.blit(wood_image,(posx,posy))
  1724. # render info line
  1725. info_string_0 = '['+key_name['wasd']+']change Size'
  1726. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']REMOVE!'
  1727. posx = 0
  1728. posy = 30
  1729. info_image = self.font.render(info_string_0,1,(255,255,255))
  1730. s.blit(info_image,(posx,posy))
  1731. posx = 0
  1732. posy = 40
  1733. info_image = self.font.render(info_string_1,1,(255,255,255))
  1734. s.blit(info_image,(posx,posy))
  1735. wood_need = 0
  1736. stone_need = 0
  1737. if game_options.mousepad == 0:
  1738. s_help = pygame.Surface((640,360))
  1739. s_help.fill((255,0,255))
  1740. s_help.blit(s,(80,0))
  1741. s = s_help
  1742. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  1743. s = s.convert_alpha()
  1744. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1745. bg.blit(s,(0,0))
  1746. self.screen.blit(bg,(0,0))
  1747. pygame.display.flip()
  1748. return (wood_need,stone_need)
  1749. def render_place(self,tile,use_name):
  1750. global player
  1751. x = player.pos[0]
  1752. y = player.pos[1]
  1753. start_pos_x = 256 #the center of the main map view
  1754. start_pos_y = 192
  1755. run = True
  1756. while run:
  1757. lootable = False
  1758. placeable = True
  1759. plantable = False
  1760. #1: check if lootable
  1761. for i in range(9,14):
  1762. if tile.techID == tl.tlist['functional'][i].techID:#this is a workbench
  1763. lootable = True
  1764. if tile.use_group == 'gather':
  1765. lootable = True
  1766. #2: check if placeable
  1767. if world.maplist[player.pos[2]][player.on_map].tilemap[y][x].move_group != 'soil' and world.maplist[player.pos[2]][player.on_map].tilemap[y][x].move_group != 'dry_entrance':
  1768. placeable = False
  1769. if world.maplist[player.pos[2]][player.on_map].tilemap[y][x].replace != None:
  1770. placeable = False
  1771. if world.maplist[player.pos[2]][player.on_map].npcs[y][x] != 0:
  1772. placeable = False
  1773. if tile.move_group != 'soil':
  1774. if x == player.pos[0] and y == player.pos[1]:
  1775. placeable = False
  1776. if use_name == 'place(indoor)':
  1777. if world.maplist[player.pos[2]][player.on_map].tilemap[y][x].indoor == False:
  1778. placeable = False
  1779. if use_name == 'place(outdoor)':
  1780. if world.maplist[player.pos[2]][player.on_map].tilemap[y][x].indoor == True:
  1781. placeable = False
  1782. #2.5: check if plantable
  1783. if world.maplist[player.pos[2]][player.on_map].tilemap[y][x].can_grown == True:
  1784. plantable = True
  1785. if use_name != 'plant':
  1786. plantable = True #if the object to be placeced no plant plantable is always true
  1787. #3: render
  1788. self.render(0,True)
  1789. s = pygame.Surface((640,360))
  1790. s.fill((255,0,255))
  1791. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1792. string1 ='~'+tile.name+'~'
  1793. string1_image = self.font.render(string1,1,(255,255,255))
  1794. s.blit(string1_image,(0,0))
  1795. if lootable == False:
  1796. warning = self.font.render('Can\'t be moved later!',1,(200,0,0))
  1797. s.blit(warning,(0,20))
  1798. string2 = '['+key_name['wasd']+']Move ['+key_name['e']+']Place! ['+key_name['x']+']Leave'
  1799. string2_image = self.font.render(string2,1,(255,255,255))
  1800. s.blit(string2_image,(0,40))
  1801. xx = x - player.pos[0]
  1802. yy = y - player.pos[1]
  1803. if placeable == True and plantable == True:
  1804. s.blit(gra_files.gdic['built'][18],(start_pos_x+(xx*32),start_pos_y+(yy*32)))
  1805. else:
  1806. s.blit(gra_files.gdic['built'][17],(start_pos_x+(xx*32),start_pos_y+(yy*32)))
  1807. if game_options.mousepad == 0:
  1808. s_help = pygame.Surface((640,360))
  1809. s_help.fill((255,0,255))
  1810. s_help.blit(s,(80,0))
  1811. s = s_help
  1812. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  1813. s = s.convert_alpha()
  1814. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1815. self.screen.blit(s,(0,0))
  1816. pygame.display.flip()
  1817. #4: user input
  1818. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  1819. if ui == 'exit':
  1820. global master_loop
  1821. global playing
  1822. global exitgame
  1823. exitgame = True
  1824. try:
  1825. save_options(game_options,options_path,os.sep)
  1826. screen.render_load(5)
  1827. save(world,player,time,gods,save_path,os.sep)
  1828. screen.save_tmp_png()
  1829. del player
  1830. except:
  1831. None
  1832. master_loop = False
  1833. playing = False
  1834. run = False
  1835. return('exit')
  1836. if ui == 'w':
  1837. if y > 0 and y > player.pos[1]-2:
  1838. y -= 1
  1839. elif ui == 's':
  1840. if y < max_map_size-1 and y < player.pos[1]+2:
  1841. y += 1
  1842. elif ui == 'a':
  1843. if x > 0 and x > player.pos[0]-2:
  1844. x -= 1
  1845. elif ui == 'd':
  1846. if x < max_map_size-1 and x < player.pos[0]+2:
  1847. x += 1
  1848. elif ui == 'e':
  1849. if placeable == True and plantable == True:
  1850. replace = world.maplist[player.pos[2]][player.on_map].tilemap[y][x]
  1851. world.maplist[player.pos[2]][player.on_map].tilemap[y][x] = deepcopy(tile)
  1852. world.maplist[player.pos[2]][player.on_map].tilemap[y][x].replace = deepcopy(replace)
  1853. world.maplist[player.pos[2]][player.on_map].tilemap[y][x].civilisation = True
  1854. if world.maplist[player.pos[2]][player.on_map].tilemap[y][x].techID == tl.tlist['misc'][0].techID or world.maplist[player.pos[2]][player.on_map].tilemap[y][x].techID == tl.tlist['global_caves'][4].techID:
  1855. world.maplist[player.pos[2]][player.on_map].tilemap[y][x].replace = None
  1856. world.maplist[player.pos[2]][player.on_map].tilemap[y][x].civilisation = False
  1857. if use_name == 'plant':
  1858. mes = 'You planted a '+tile.name+'.'
  1859. else:
  1860. mes = 'You placed a '+tile.name+'.'
  1861. message.add(mes)
  1862. return(x,y)
  1863. elif ui == 'x':
  1864. run = False
  1865. return False
  1866. return False#only to be sure
  1867. def render_textbox_open(self):
  1868. clock = pygame.time.Clock()
  1869. for i in range(-64,1,6):
  1870. s = pygame.Surface((320,240))
  1871. s.fill((255,0,255))
  1872. s.blit(gra_files.gdic['display'][5],(0,i)) #render gui_transparent over gui
  1873. if game_options.mousepad == 0:
  1874. s_help = pygame.Surface((640,360))
  1875. s_help.fill((255,0,255))
  1876. s_help.blit(s,(80,0))
  1877. s = s_help
  1878. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  1879. s = s.convert_alpha()
  1880. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1881. self.screen.blit(s,(0,0))
  1882. pygame.display.flip()
  1883. clock.tick(256)
  1884. def render_request(self,line1,line2,line3,first_call=True,portrait=None):
  1885. #this function just renders 3 lines of text in the textbox
  1886. self.render(0, True)
  1887. if first_call == True:
  1888. self.render_textbox_open()
  1889. s = pygame.Surface((640,380))
  1890. s.fill((255,0,255))
  1891. if portrait != None:
  1892. s.blit(gra_files.portraits[portrait],(180,0))
  1893. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1894. # render lines
  1895. line1_image = self.font.render(line1,1,(255,255,255))
  1896. posx = 0
  1897. posy = 0
  1898. s.blit(line1_image,(posx,posy))
  1899. line2_image = self.font.render(line2,1,(255,255,255))
  1900. posx = 0
  1901. posy = 20
  1902. s.blit(line2_image,(posx,posy))
  1903. line3_image = self.font.render(line3,1,(255,255,255))
  1904. posx = 0
  1905. posy = 40
  1906. s.blit(line3_image,(posx,posy))
  1907. if game_options.mousepad == 0:
  1908. s_help = pygame.Surface((640,360))
  1909. s_help.fill((255,0,255))
  1910. s_help.blit(s,(80,0))
  1911. s = s_help
  1912. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  1913. s = s.convert_alpha()
  1914. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1915. self.screen.blit(s,(0,0))
  1916. pygame.display.flip()
  1917. def render_map(self,level=0):
  1918. run = True
  1919. while run:
  1920. m = pygame.Surface((max_map_size,max_map_size))
  1921. for y in range(0,max_map_size):
  1922. for x in range(0,max_map_size):
  1923. try:
  1924. t_col = world.maplist[level][player.on_map].tilemap[y][x].tile_color
  1925. except:
  1926. level = 0
  1927. t_col = world.maplist[level][player.on_map].tilemap[y][x].tile_color
  1928. if x > player.pos[0]-2 and x < player.pos[0]+2 and y > player.pos[1]-2 and y < player.pos[1]+2 and level == player.pos[2]: #mark players pos
  1929. m.blit(gra_files.gdic['tile1']['white'],(x,y))
  1930. else:
  1931. if world.maplist[level][player.on_map].known[y][x] == 1:
  1932. m.blit(gra_files.gdic['tile1'][t_col],(x,y))
  1933. elif world.maplist[level][player.on_map].known[y][x] == 0:
  1934. m.blit(gra_files.gdic['tile1']['black'],(x,y))
  1935. else:
  1936. m.blit(gra_files.gdic['tile1']['black'],(x,y))
  1937. m = pygame.transform.scale(m,(270,270))
  1938. s = pygame.Surface((640,360))
  1939. bg = pygame.Surface((480,360))
  1940. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  1941. s.blit(bg,(0,0))
  1942. if game_options.mousepad == 1:
  1943. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  1944. else:
  1945. s_help = pygame.Surface((160,360))
  1946. s_help.fill((48,48,48))
  1947. s.blit(s_help,(480,0))
  1948. text = '~Map~ [Press['+key_name['x']+'] to leave'
  1949. text_image = screen.font.render(text,1,(255,255,255))
  1950. s.blit(text_image,(5,2))#menue title
  1951. lvl_string = 'Level ' + str(level)
  1952. text_image = screen.font.render(lvl_string,1,(0,0,0))
  1953. if low_res == False:
  1954. s.blit(text_image,(300,70))
  1955. else:
  1956. s.blit(text_image,(190,50))
  1957. s.blit(m,(25,55))
  1958. if game_options.mousepad == 0:
  1959. s_help = pygame.Surface((640,360))
  1960. s_help.fill((48,48,48))
  1961. s_help.blit(s,(80,0))
  1962. s = s_help
  1963. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1964. self.screen.blit(s,(0,0))
  1965. pygame.display.flip()
  1966. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  1967. if ui == 'exit':
  1968. global master_loop
  1969. global playing
  1970. global exitgame
  1971. exitgame = True
  1972. screen.render_load(5)
  1973. save(world,player,time,gods,save_path,os.sep)
  1974. screen.save_tmp_png()
  1975. master_loop = False
  1976. playing = False
  1977. run = False
  1978. return('exit')
  1979. if ui == 'x':
  1980. run = False
  1981. def render_credits(self):
  1982. global master_loop
  1983. run = True
  1984. while run:
  1985. s = pygame.Surface((640,360))
  1986. bg = pygame.Surface((480,360))
  1987. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  1988. s.blit(bg,(0,0))
  1989. if game_options.mousepad == 1 and low_res == False:
  1990. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  1991. else:
  1992. s_help = pygame.Surface((160,360))
  1993. s_help.fill((48,48,48))
  1994. s.blit(s_help,(480,0))
  1995. text = '~Credits~ [Press ['+key_name['x']+'] to leave]'
  1996. text_image = screen.font.render(text,1,(255,255,255))
  1997. s.blit(text_image,(5,2))#menue title
  1998. credit_items = ('Code & Art: The Mighty Glider [GPL3+/CC0]', 'BGM: Various Artists [CC0]' , 'SFX: Various Artists [CC0]', 'Portraits: PlayCraft/ZeNeRIA29 [CC-BY-SA 3.0]' , 'Font: Cody Boisclair', 'Testing: eugeneloza', 'Special Thanks: forum.freegamedev.net', ' !freegaming@quitter.se')
  1999. for i in range (0,len(credit_items)):
  2000. text_image = screen.font.render(credit_items[i],1,(0,0,0))
  2001. s.blit(text_image,(21,120+i*25))#blit credit_items
  2002. if game_options.mousepad == 0:
  2003. s_help = pygame.Surface((640,360))
  2004. s_help.fill((48,48,48))
  2005. s_help.blit(s,(80,0))
  2006. s = s_help
  2007. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  2008. self.screen.blit(s,(0,0))
  2009. pygame.display.flip()
  2010. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2011. if ui == 'exit':
  2012. master_loop = False
  2013. run = False
  2014. return('exit')
  2015. if ui == 'x':
  2016. run = False
  2017. def render_status(self):
  2018. player_attribute = ('Strength: '+str(player.attribute.p_strength),
  2019. 'Skill: '+str(player.attribute.p_defense),
  2020. 'Power: '+str(player.attribute.m_strength),
  2021. 'Will: '+str(player.attribute.m_defense),
  2022. 'Health: '+str(player.lp)+'/'+str(player.attribute.max_lp),
  2023. '--> SKILLS')
  2024. attribute_info = ('Strength','Skill','Power','Will','Health')
  2025. if player.skill.woodcutting == 'Novice':
  2026. woodcutting_next_lvl = '200'
  2027. else:
  2028. woodcutting_next_lvl = '1000'
  2029. if player.skill.mining == 'Novice':
  2030. mining_next_lvl = '200'
  2031. else:
  2032. mining_next_lvl = '1000'
  2033. if len(player.buffs.buff_list) > 0:
  2034. next_str = 'BUFFS -->'
  2035. else:
  2036. next_str = '<-- ATTRIBUTES'
  2037. player_skills = ('Weapon Crafting: '+player.skill.weapon_crafting,
  2038. 'Metallurgy: '+player.skill.metallurgy,
  2039. 'Alchemy: '+player.skill.alchemy,
  2040. 'Woodcutting: '+player.skill.woodcutting+' ('+str(player.skill.woodcutting_progress)+'/'+woodcutting_next_lvl+')',
  2041. 'Mining: '+player.skill.mining+' ('+str(player.skill.mining_progress)+'/'+mining_next_lvl+')',
  2042. next_str)
  2043. skill_info = ('Weapon Crafting','Metallurgy','Alchemy','Woodcutting','Mining')
  2044. buff_strings = list(player.buffs.buff_list.keys())
  2045. player_buffs = []
  2046. if len(player.buffs.buff_list) > 0:
  2047. for i in buff_strings:
  2048. player_buffs.append(i.upper())
  2049. player_buffs.append('<-- ATTRIBUTES')
  2050. run = True
  2051. while run:
  2052. c = screen.get_choice('Attributes',player_attribute,True)
  2053. if c == 'Break':
  2054. run = False
  2055. return False
  2056. if c < 5:
  2057. screen.render_text(texts[attribute_info[c]])
  2058. elif c == 5:
  2059. run2 = True
  2060. while run2:
  2061. d = screen.get_choice('Skills',player_skills,True)
  2062. if d == 'Break':
  2063. run = False
  2064. run2 = False
  2065. return False
  2066. if d < 5:
  2067. screen.render_text(texts[skill_info[d]])
  2068. elif d == 5:
  2069. if len(player.buffs.buff_list) > 0:
  2070. run3 = True
  2071. while run3:
  2072. d = screen.get_choice('Buffs',player_buffs,True)
  2073. if d == 'Break':
  2074. run = False
  2075. run2 = False
  2076. run3 = False
  2077. return False
  2078. if d < len(player.buffs.buff_list):
  2079. try:
  2080. screen.render_text(texts[buff_strings[d]])
  2081. except:
  2082. screen.render_text(texts['unknown buff'])
  2083. elif d == len(player.buffs.buff_list):
  2084. run2 = False
  2085. run3 = False
  2086. else:
  2087. run2 = False
  2088. def render_text(self,text,replace_keys=True,more_txt=False,simulation= False):
  2089. run = True
  2090. while run:
  2091. if low_res == False:
  2092. s = pygame.Surface((640,360))
  2093. else:
  2094. s = pygame.Surface((320,240))
  2095. bg = pygame.Surface((480,360))
  2096. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  2097. if low_res == True:
  2098. bg = pygame.transform.scale(bg,(320,240))
  2099. s.blit(bg,(0,0))
  2100. if game_options.mousepad == 1 and low_res == False:
  2101. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2102. else:
  2103. s_help = pygame.Surface((160,360))
  2104. s_help.fill((48,48,48))
  2105. s.blit(s_help,(480,0))
  2106. if simulation == False:
  2107. if more_txt == False:
  2108. top_text = '[Press ['+key_name['x']+'] to leave]'
  2109. else:
  2110. top_text = '[Press ['+key_name['e']+'] for next page]'
  2111. text_image = screen.font.render(top_text,1,(255,255,255))
  2112. s.blit(text_image,(5,2))#menue title
  2113. for i in range (0,len(text)):
  2114. text_image = screen.font.render(text[i],1,(0,0,0))
  2115. if low_res == False:
  2116. s.blit(text_image,(60,80+i*25))#blit credit_items
  2117. else:
  2118. s.blit(text_image,(21,36+i*20))#blit credit_items
  2119. if simulation == True:
  2120. return s
  2121. if game_options.mousepad == 0 and low_res == False:
  2122. s_help = pygame.Surface((640,360))
  2123. s_help.fill((48,48,48))
  2124. s_help.blit(s,(80,0))
  2125. s = s_help
  2126. if low_res == False:
  2127. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  2128. self.screen.blit(s,(0,0))
  2129. pygame.display.flip()
  2130. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2131. if ui == 'exit':
  2132. global master_loop
  2133. global playing
  2134. global exitgame
  2135. exitgame = True
  2136. try:
  2137. screen.render_load(5)
  2138. save(world,player,time,gods,save_path,os.sep)
  2139. screen.save_tmp_png()
  2140. del player
  2141. except:
  2142. None
  2143. master_loop = False
  2144. playing = False
  2145. run = False
  2146. return('exit')
  2147. if ui == 'x':
  2148. run = False
  2149. elif ui == 'e' and more_txt == True:
  2150. run = False
  2151. def render_multi_text(self,texts):
  2152. run = True
  2153. page = 0
  2154. total_pages = len(texts)
  2155. while run:
  2156. s = self.render_text(texts[page],simulation=True)
  2157. page_txt = 'Page '+str(page+1)+ ' of '+str(total_pages)+' ['+key_name['x']+'] - leave'
  2158. page_image = screen.font.render(page_txt,1,(255,255,255))
  2159. s.blit(page_image,(5,2))#menue title
  2160. if game_options.mousepad == 0 and low_res == False:
  2161. s_help = pygame.Surface((640,360))
  2162. s_help.fill((48,48,48))
  2163. s_help.blit(s,(80,0))
  2164. s = s_help
  2165. if low_res == False:
  2166. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  2167. self.screen.blit(s,(0,0))
  2168. pygame.display.flip()
  2169. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2170. if ui == 's' or ui == 'd':
  2171. page += 1
  2172. if page > total_pages-1:
  2173. page = 0
  2174. elif ui == 'w' or ui == 'a':
  2175. page -= 1
  2176. if page < 0:
  2177. page = total_pages-1
  2178. elif ui == 'x':
  2179. run = False
  2180. def render_options(self):
  2181. global key_name
  2182. run = True
  2183. num = 0
  2184. options_path = save_path
  2185. for c in range(0,5):
  2186. options_path = options_path.replace(os.sep + 'World' + str(c),'')
  2187. while run:
  2188. if game_options.screenmode == 2:
  2189. winm = 'Screenmode: Fullscreen'
  2190. elif game_options.screenmode == 1:
  2191. winm = 'Screenmode: Windowed(1280X720)'
  2192. else:
  2193. winm = 'Screenmode: Windowed(640X360)'
  2194. if game_options.bgmmode != 0:
  2195. audiom = 'BGM: ' + str(int(game_options.bgmmode*100)) + '%'
  2196. else:
  2197. audiom = 'BGM: OFF'
  2198. if game_options.sfxmode != 0:
  2199. sfxm = 'SFX: ' +str(int(game_options.sfxmode*100)) + '%'
  2200. else:
  2201. sfxm = 'SFX: OFF'
  2202. if game_options.turnmode == 1:
  2203. turnm = 'Gamemode: Semi-Realtime'
  2204. else:
  2205. turnm = 'Gamemode: Turnbased'
  2206. if game_options.mousepad == 1:
  2207. mousem = 'Use Mouse: yes'
  2208. else:
  2209. mousem = 'Use Mouse: no'
  2210. if game_options.check_version == 1:
  2211. versm = 'Check Version: yes'
  2212. else:
  2213. versm = 'Check Version: no'
  2214. if game_options.rendermode == 1:
  2215. renderm = 'Rendermode: fast'
  2216. else:
  2217. renderm = 'Rendermode: fancy'
  2218. if game_options.input_nomination == 0:
  2219. inputm = 'Input Designation: Keyboard'
  2220. elif game_options.input_nomination == 1:
  2221. inputm = 'Input Designation: Joystick (Numeric)'
  2222. else:
  2223. inputm = 'Input Designation: Joystick (A,B,X,Y)'
  2224. s = pygame.Surface((640,360))
  2225. bg = pygame.Surface((480,360))
  2226. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  2227. if low_res == True:
  2228. bg = pygame.transform.scale(bg,(320,240))
  2229. s.blit(bg,(0,0))
  2230. text = '~Options~ [Press ['+key_name['e']+'] to choose]'
  2231. text_image = screen.font.render(text,1,(255,255,255))
  2232. s.blit(text_image,(5,2))#menue title
  2233. menu_items = (winm,renderm,audiom,sfxm,turnm,mousem,inputm,versm,'Done')
  2234. for i in range (0,len(menu_items)):
  2235. text_image = screen.font.render(menu_items[i],1,(0,0,0))
  2236. s.blit(text_image,(21,100+i*25))#blit menu_items
  2237. s.blit(gra_files.gdic['display'][4],(0,93+num*25))#blit marker
  2238. if game_options.mousepad == 1:
  2239. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2240. else:
  2241. s_help = pygame.Surface((160,360))
  2242. s_help.fill((48,48,48))
  2243. s.blit(s_help,(480,0))
  2244. if game_options.mousepad == 0:
  2245. s_help = pygame.Surface((640,360))
  2246. s_help.fill((48,48,48))
  2247. s_help.blit(s,(80,0))
  2248. s = s_help
  2249. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  2250. self.screen.blit(s,(0,0))
  2251. pygame.display.flip()
  2252. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2253. if ui == 'exit':
  2254. global master_loop
  2255. global playing
  2256. global exitgame
  2257. global player
  2258. exitgame = True
  2259. try:
  2260. save_options(game_options,options_path,os.sep)
  2261. screen.render_load(5)
  2262. save(world,player,time,gods,save_path,os.sep)
  2263. screen.save_tmp_png()
  2264. del player
  2265. except:
  2266. None
  2267. master_loop = False
  2268. playing = False
  2269. run = False
  2270. return('exit')
  2271. if ui == 'w':
  2272. num -= 1
  2273. if num < 0:
  2274. num = len(menu_items)-1
  2275. if ui == 's':
  2276. num += 1
  2277. if num >= len(menu_items):
  2278. num = 0
  2279. if ui == 'x':
  2280. run = False
  2281. if ui == 'e':
  2282. if num == 0:
  2283. screen.re_init()
  2284. pygame.display.flip()
  2285. save_options(game_options,options_path,os.sep)
  2286. if num == 1:
  2287. if game_options.rendermode == 0:
  2288. game_options.rendermode = 1
  2289. else:
  2290. game_options.rendermode = 0
  2291. if num == 2:
  2292. ui = screen.get_choice('BGM Loudness',('OFF','25%','50%','75%','100%'),True)
  2293. if ui == 0:
  2294. game_options.bgmmode = 0
  2295. pygame.mixer.music.pause()
  2296. elif ui == 1:
  2297. game_options.bgmmode = 0.25
  2298. pygame.mixer.music.unpause()
  2299. bgm.check_for_song(force_play=True)
  2300. elif ui == 2:
  2301. game_options.bgmmode = 0.5
  2302. pygame.mixer.music.unpause()
  2303. bgm.check_for_song(force_play=True)
  2304. elif ui == 3:
  2305. game_options.bgmmode = 0.75
  2306. pygame.mixer.music.unpause()
  2307. bgm.check_for_song(force_play=True)
  2308. elif ui == 4:
  2309. game_options.bgmmode = 1
  2310. pygame.mixer.music.unpause()
  2311. bgm.check_for_song(force_play=True)
  2312. save_options(game_options,options_path,os.sep)
  2313. if num == 3:
  2314. ui = screen.get_choice('SFX Loudness',('OFF','25%','50%','75%','100%'),True)
  2315. if ui == 0:
  2316. game_options.sfxmode = 0
  2317. elif ui == 1:
  2318. game_options.sfxmode = 0.25
  2319. sfx.set_loudness()
  2320. elif ui == 2:
  2321. game_options.sfxmode = 0.5
  2322. sfx.set_loudness()
  2323. elif ui == 3:
  2324. game_options.sfxmode = 0.75
  2325. sfx.set_loudness()
  2326. elif ui == 4:
  2327. game_options.sfxmode = 1
  2328. sfx.set_loudness()
  2329. save_options(game_options,options_path,os.sep)
  2330. if num == 4:
  2331. if game_options.turnmode == 1:
  2332. game_options.turnmode = 0
  2333. else:
  2334. game_options.turnmode = 1
  2335. save_options(game_options,options_path,os.sep)
  2336. if num == 5 and low_res == False:
  2337. if game_options.mousepad == 1:
  2338. game_options.mousepad = 0
  2339. else:
  2340. game_options.mousepad = 1
  2341. pygame.mouse.set_visible(game_options.mousepad)
  2342. save_options(game_options,options_path,os.sep)
  2343. if num == 6:
  2344. if game_options.input_nomination == 0:
  2345. game_options.input_nomination = 1
  2346. elif game_options.input_nomination == 1:
  2347. game_options.input_nomination = 2
  2348. else:
  2349. game_options.input_nomination = 0
  2350. if game_options.input_nomination == 0:
  2351. key_name = {'e':'e','b':'b','x':'x','f':'f','i':'i','.':'.','wasd':'w,s,a,d','ws':'w,s'}
  2352. elif game_options.input_nomination == 1:
  2353. key_name = {'e':'1','b':'3','x':'2','f':'5','i':'4','.':'6','wasd':'D-Pad','ws':'D-Pad'}
  2354. else:
  2355. key_name = {'e':'A','b':'X','x':'B','f':'R','i':'Y','.':'R','wasd':'D-Pad','ws':'D-Pad'}
  2356. if num == 7:
  2357. if game_options.check_version == 1:
  2358. game_options.check_version = 0
  2359. else:
  2360. game_options.check_version = 1
  2361. save_options(game_options,options_path,os.sep)
  2362. if num == 8:
  2363. save_options(game_options,options_path,os.sep)
  2364. run = False
  2365. def render_brake(self,simulate= False):
  2366. run = True
  2367. num = 0
  2368. global exitgame
  2369. global playing
  2370. global player
  2371. while run:
  2372. if low_res == False:
  2373. s = pygame.Surface((640,360))
  2374. else:
  2375. s = pygame.Surface((320,240))
  2376. bg = pygame.Surface((480,360))
  2377. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  2378. if low_res == True:
  2379. bg = pygame.transform.scale(bg,(320,240))
  2380. s.blit(bg,(0,0))
  2381. text = '~Game Paused~ [Press ['+key_name['e']+'] to choose]'
  2382. text_image = screen.font.render(text,1,(255,255,255))
  2383. s.blit(text_image,(5,2))#menue title
  2384. menu_items = ('Resume','Status','Message History','Save and Exit', 'Options',)
  2385. for i in range (0,len(menu_items)):
  2386. text_image = screen.font.render(menu_items[i],1,(0,0,0))
  2387. if low_res == False:
  2388. s.blit(text_image,(21,120+i*25))#blit menu_items
  2389. else:
  2390. s.blit(text_image,(21,46+i*25))#blit menu_items
  2391. if low_res == False:
  2392. s.blit(gra_files.gdic['display'][4],(0,112+num*25))#blit marker
  2393. else:
  2394. s.blit(gra_files.gdic['display'][4],(0,38+num*25))#blit marker
  2395. if game_options.mousepad == 1 and low_res != True:
  2396. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2397. else:
  2398. s_help = pygame.Surface((160,360))
  2399. s_help.fill((48,48,48))
  2400. s.blit(s_help,(480,0))
  2401. if game_options.mousepad == 0 and low_res == False:
  2402. s_help = pygame.Surface((640,360))
  2403. s_help.fill((48,48,48))
  2404. s_help.blit(s,(80,0))
  2405. s = s_help
  2406. if low_res == False:
  2407. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  2408. if simulate == True:
  2409. return s
  2410. self.screen.blit(s,(0,0))
  2411. pygame.display.flip()
  2412. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2413. if ui == 'exit':
  2414. global master_loop
  2415. global playing
  2416. global exitgame
  2417. exitgame = True
  2418. screen.render_load(5)
  2419. save(world,player,time,gods,save_path,os.sep)
  2420. screen.save_tmp_png()
  2421. master_loop = False
  2422. playing = False
  2423. run = False
  2424. return('exit')
  2425. if ui == 'w':
  2426. num -= 1
  2427. if num < 0:
  2428. num = len(menu_items)-1
  2429. if ui == 's':
  2430. num += 1
  2431. if num >= len(menu_items):
  2432. num = 0
  2433. if ui == 'x':
  2434. run = False
  2435. screen.render_fade(True,False,'screen')
  2436. if ui == 'e':
  2437. if num == 0:
  2438. run = False
  2439. screen.render_fade(True,False,'screen')
  2440. if num == 1:
  2441. screen.render_status()
  2442. if num == 2:
  2443. do = message.render_history()
  2444. if do == 'exit':
  2445. run = False
  2446. if num == 3:
  2447. exitgame = True
  2448. screen.render_load(5)
  2449. save(world,player,time,gods,save_path,os.sep)
  2450. screen.save_tmp_png()
  2451. del player
  2452. playing = False
  2453. run = False
  2454. if num == 4:
  2455. do = screen.render_options()
  2456. if do == 'exit':
  2457. run = False
  2458. return exitgame
  2459. def get_choice(self,headline,choices,allow_chancel,style='Default'):
  2460. #this function allows the player to make a coice. The choices-variable is a tulpel with strings. The function returns the number of the chosen string inside the tulpel
  2461. run = True
  2462. num = 0
  2463. while run:
  2464. s = pygame.Surface((640,360))
  2465. bg = pygame.Surface((480,360))
  2466. if style == 'Default':
  2467. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  2468. elif style == 'Warning':
  2469. bg.blit(gra_files.gdic['display'][17],(0,0))
  2470. s.blit(bg,(0,0))
  2471. text_image = screen.font.render(headline,1,(255,255,255))
  2472. if low_res == False:
  2473. s.blit(text_image,(5,2))#menue title
  2474. else:
  2475. s.blit(text_image,(0,2))#menue title
  2476. menu_items = choices
  2477. for i in range (0,len(menu_items)):
  2478. text_image = screen.font.render(menu_items[i],1,(0,0,0))
  2479. if low_res == False:
  2480. s.blit(text_image,(21,120+i*25))#blit menu_items
  2481. else:
  2482. s.blit(text_image,(21,46+i*25))#blit menu_items
  2483. if allow_chancel == True:
  2484. string = '['+key_name['e']+'] - choose ['+key_name['x']+'] - leave'
  2485. text_image = screen.font.render(string,1,(255,255,255))
  2486. if low_res == True:
  2487. s.blit(text_image,(0,225))
  2488. else:
  2489. s.blit(text_image,(5,335))
  2490. else:
  2491. string = '['+key_name['e']+'] - choose'
  2492. text_image = screen.font.render(string,1,(255,255,255))
  2493. if low_res == True:
  2494. s.blit(text_image,(0,225))
  2495. else:
  2496. s.blit(text_image,(5,335))
  2497. if style == 'Default':
  2498. if low_res == False:
  2499. s.blit(gra_files.gdic['display'][4],(0,112+num*25))#blit marker
  2500. else:
  2501. s.blit(gra_files.gdic['display'][4],(0,38+num*25))#blit marker
  2502. elif style == 'Warning':
  2503. if low_res == False:
  2504. s.blit(gra_files.gdic['display'][18],(0,112+num*25))#blit marker
  2505. else:
  2506. s.blit(gra_files.gdic['display'][18],(0,38+num*25))#blit marker
  2507. if game_options.mousepad == 1:
  2508. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2509. else:
  2510. s_help = pygame.Surface((160,360))
  2511. s_help.fill((48,48,48))
  2512. s.blit(s_help,(480,0))
  2513. if game_options.mousepad == 0:
  2514. s_help = pygame.Surface((640,360))
  2515. s_help.fill((48,48,48))
  2516. s_help.blit(s,(80,0))
  2517. s = s_help
  2518. else:
  2519. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2520. s = pygame.transform.scale(s,(screen.displayx,screen.displayy))
  2521. screen.screen.blit(s,(0,0))
  2522. pygame.display.flip()
  2523. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2524. if ui == 'exit':
  2525. global master_loop
  2526. global playing
  2527. global exitgame
  2528. global player
  2529. exitgame = True
  2530. try:
  2531. screen.render_load(5)
  2532. save(world,player,time,gods,save_path,os.sep)
  2533. screen.save_tmp_png()
  2534. except:
  2535. None
  2536. master_loop = False
  2537. playing = False
  2538. run = False
  2539. return('exit')
  2540. if ui == 'w':
  2541. num -= 1
  2542. if num < 0:
  2543. num = len(menu_items)-1
  2544. if ui == 's':
  2545. num += 1
  2546. if num >= len(menu_items):
  2547. num = 0
  2548. if ui == 'e':
  2549. run = False
  2550. return num
  2551. if ui == 'x' and allow_chancel == True:
  2552. run = False
  2553. return 'Break'
  2554. def string_input(self, input_message, length):
  2555. run = True
  2556. string = ''
  2557. pos = 0
  2558. x = 0
  2559. y = 0
  2560. char_field = (('A','B','C','D','E','F','G','H','a','b','c','d','e','f','g','h'),('I','J','K','L','M','N','O','P','i','j','k','l','m','n','o','p'),('Q','R','S','T','U','V','W','X','q','r','s','t','u','v','w','x'),('Y','Z','y','z','0','1','2','3','4','5','6','7','8','9', '.',','),('(','[','<','{',')',']','>','}','#','+','-','_','*','/','&','%'))
  2561. while run:
  2562. s = pygame.Surface((640,360))
  2563. s.blit(gra_files.gdic['display'][1],(0,0)) #render background
  2564. text_image = screen.font.render(input_message,1,(255,255,255))
  2565. s.blit(text_image,(5,2))#menue title
  2566. num_stars = length - len(string)
  2567. star_string = ''
  2568. if num_stars > 0:
  2569. for i in range (0,num_stars):
  2570. star_string += '*'
  2571. shown_string = string + '_' + star_string
  2572. string_image = screen.font.render(shown_string,1,(255,255,255))
  2573. s.blit(string_image,(5,35))#string so far
  2574. for i in range (0,5):#blit chars
  2575. for j in range (0,len(char_field[1])):
  2576. if i == y and j == x:
  2577. char_image = screen.font.render(char_field[i][j],1,(255,255,255))
  2578. else:
  2579. char_image = screen.font.render(char_field[i][j],1,(0,0,0))
  2580. if low_res == False:
  2581. s.blit(char_image,(55+(j*20),150+(i*20)))
  2582. else:
  2583. s.blit(char_image,(5+(j*20),90+(i*20)))
  2584. if game_options.mousepad == 1 and low_res == False:
  2585. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2586. else:
  2587. s_help = pygame.Surface((160,360))
  2588. s_help.fill((48,48,48))
  2589. s.blit(s_help,(480,0))
  2590. text = '['+key_name['e']+'] - Add Char ['+key_name['x']+'] - Del Char ['+key_name['b']+'] - Done'
  2591. text_image = screen.font.render(text,1,(255,255,255))
  2592. if low_res == False:
  2593. s.blit(text_image,(5,335))
  2594. else:
  2595. help_sur = pygame.Surface((320,16))
  2596. help_sur.fill((48,48,48))
  2597. help_sur.blit(text_image,(5,5))
  2598. s.blit(help_sur,(0,224))
  2599. if game_options.mousepad == 0 and low_res == False:
  2600. s_help = pygame.Surface((640,360))
  2601. s_help.fill((48,48,48))
  2602. s_help.blit(s,(80,0))
  2603. s = s_help
  2604. if low_res == False:
  2605. s = pygame.transform.scale(s,(screen.displayx,screen.displayy))
  2606. screen.screen.blit(s,(0,0))
  2607. pygame.display.flip()
  2608. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2609. if ui == 'w':
  2610. y -= 1
  2611. if y < 0:
  2612. y = 4
  2613. if ui == 's':
  2614. y += 1
  2615. if y > 4:
  2616. y = 0
  2617. if ui == 'a':
  2618. x -= 1
  2619. if x < 0:
  2620. x = len(char_field[1])-1
  2621. if ui == 'd':
  2622. x += 1
  2623. if x > len(char_field[1])-1:
  2624. x = 0
  2625. if ui == 'e':
  2626. if pos <= length:
  2627. string += char_field[y][x]
  2628. pos += 1
  2629. if ui == 'b':
  2630. run = False
  2631. if ui == 'x':
  2632. if pos > 0:
  2633. pos -= 1
  2634. string = string[:pos]
  2635. return string
  2636. def render_dead(self):
  2637. global exitgame
  2638. self.reset_hit_matrix()
  2639. if player.godmode == True:
  2640. player.respawn()
  2641. message.add('YOU DIE.. NOT!')
  2642. return True
  2643. run = True
  2644. while run:
  2645. if low_res == False:
  2646. s = pygame.Surface((640,360))
  2647. else:
  2648. s = pygame.Surface((320,240))
  2649. s.fill((48,48,48)) #paint it grey(to clear the screen)
  2650. text_image = screen.font.render('YOU ARE DEAD!',1,(255,255,255))
  2651. if low_res == False:
  2652. s.blit(text_image,(175,60))
  2653. else:
  2654. s.blit(text_image,(75,60))
  2655. if player.difficulty == 3: #you play on roguelike mode
  2656. choose_string = '------------- ['+key_name['x']+'] - END GAME'
  2657. else:#you play on a other mode
  2658. choose_string = '['+key_name['e']+'] - RESPAWN ['+key_name['x']+'] - END GAME'
  2659. choose_image = screen.font.render(choose_string,1,(255,255,255))
  2660. if low_res == False:
  2661. s.blit(choose_image,(125,200))
  2662. else:
  2663. s.blit(choose_image,(25,200))
  2664. if game_options.mousepad == 1 and low_res == False:
  2665. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2666. else:
  2667. s_help = pygame.Surface((160,360))
  2668. s_help.fill((48,48,48))
  2669. s.blit(s_help,(480,0))
  2670. if game_options.mousepad == 0 and low_res == False:
  2671. s_help = pygame.Surface((640,360))
  2672. s_help.fill((48,48,48))
  2673. s_help.blit(s,(80,0))
  2674. s = s_help
  2675. else:
  2676. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2677. if low_res == False:
  2678. s = pygame.transform.scale(s,(screen.displayx,screen.displayy))
  2679. screen.screen.blit(s,(0,0))
  2680. pygame.display.flip()
  2681. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2682. if ui == 'exit':
  2683. global master_loop
  2684. global playing
  2685. global exitgame
  2686. exitgame = True
  2687. if player.difficulty !=3:
  2688. screen.render_load(5)
  2689. save(world,player,time,gods,save_path,os.sep)
  2690. screen.save_tmp_png()
  2691. else:
  2692. files_to_remove = ('gods.data','player.data','world.data','time.data')
  2693. for i in files_to_remove:
  2694. del_file = save_path + os.sep + i
  2695. try:
  2696. os.remove(del_file)
  2697. except:
  2698. None
  2699. master_loop = False
  2700. playing = False
  2701. run = False
  2702. return('exit')
  2703. if ui == 'e' and player.difficulty != 3:
  2704. player.respawn()
  2705. save(world,player,time,gods,save_path,os.sep)
  2706. run = False
  2707. elif ui == 'x':
  2708. player.respawn()
  2709. if player.difficulty != 3:
  2710. screen.render_load(5)
  2711. save(world,player,time,gods,save_path,os.sep)
  2712. screen.save_tmp_png()
  2713. else:
  2714. files_to_remove = ('gods.data','player.data','world.data','time.data')
  2715. for i in files_to_remove:
  2716. del_file = save_path + os.sep + i
  2717. try:
  2718. os.remove(del_file)
  2719. except:
  2720. None
  2721. run = False
  2722. exitgame = True
  2723. class maP():
  2724. def __init__(self, name, tilemap, visit=False, map_type='overworld',monster_num=1):
  2725. self.name = name
  2726. self.known = []
  2727. self.containers = []
  2728. self.tilemap = tilemap
  2729. self.visit = visit
  2730. self.last_visit = 0 #-------test only
  2731. self.map_type = map_type
  2732. self.monster_num = monster_num
  2733. self.build_type = 'Full' #Full: build everything you want, Part: no stairs, None: Buildmode is not callable
  2734. self.thirst_multi_day = 1
  2735. self.thirst_multi_night = 1
  2736. self.no_monster_respawn = False
  2737. self.countdowns = []
  2738. self.npcs = []
  2739. self.monster_plus = 0
  2740. self.monster_count = 0
  2741. self.music_day_original = 'overworld'
  2742. self.music_day = self.music_day_original
  2743. self.music_night_original = 'night'
  2744. self.music_night = self.music_night_original
  2745. self.generation_release = release_number
  2746. for y in range (0,max_map_size):
  2747. self.known.append([])
  2748. for x in range (0,max_map_size):
  2749. self.known[y].append(0)
  2750. for y in range (0,max_map_size):
  2751. self.containers.append([])
  2752. for x in range (0,max_map_size):
  2753. self.containers[y].append(0)
  2754. for y in range (0,max_map_size):
  2755. self.npcs.append([])
  2756. for x in range (0,max_map_size):
  2757. self.npcs[y].append(0)
  2758. def fill(self, tile):
  2759. for y in range (0,max_map_size):
  2760. for x in range(0,max_map_size):
  2761. self.tilemap[y][x] = deepcopy(tile)
  2762. def check_fov(self,x,y,dist):
  2763. fov = []
  2764. startx = x-8
  2765. starty = y-6
  2766. extreme_coordinates = []
  2767. dist_coordinates = []
  2768. for yy in range(0,12):
  2769. fov.append([])
  2770. for xx in range(0,15):
  2771. fov[yy].append(0)
  2772. dist1 = ((8-xx)**2+(6-yy)**2)**0.5
  2773. if dist1 > 0:
  2774. extreme_coordinates.append((xx,yy))
  2775. dist_coordinates.append(dist1)
  2776. for i in range(0,len(extreme_coordinates)-1):
  2777. c = 0
  2778. run = True
  2779. while run:
  2780. dir_x = (8-extreme_coordinates[i][0])/dist_coordinates[i]
  2781. dir_y = (6-extreme_coordinates[i][1])/dist_coordinates[i]
  2782. lx = int(round(8+c*dir_x))
  2783. ly = int(6+c*dir_y)
  2784. if ly < 6:
  2785. ly += 1
  2786. elif ly > 6:
  2787. ly -= 1
  2788. ldist = ((8-lx)**2+(6-ly)**2)**0.5
  2789. try:
  2790. fov[ly][lx] = 1
  2791. except:
  2792. None
  2793. c+=1
  2794. if lx < 0 or lx > 14 or ly < 0 or ly > 11:
  2795. run = False
  2796. elif ldist >= dist:
  2797. run = False
  2798. elif self.tilemap[starty+ly][startx+lx].transparency == False:
  2799. run = False
  2800. return fov
  2801. def check_los(self,startx,starty,endx,endy):
  2802. try:
  2803. if startx > max_map_size or startx < 0 or endx > max_map_size or endx < 0 or starty > max_map_size or starty < 0 or endy > max_map_size or endy < 0:
  2804. return False
  2805. vector = (endx-startx,endy-starty)
  2806. dist = (vector[0]**2+vector[1]**2)**0.5
  2807. try:
  2808. test1 = self.npcs[starty][startx].inner_view_range
  2809. test2 = self.npcs[starty][startx].outer_view_range
  2810. test3 = self.npcs[starty][startx].active
  2811. except:
  2812. self.npcs[starty][startx].inner_view_range = 5
  2813. self.npcs[starty][startx].outer_view_range = 8
  2814. self.npcs[starty][startx].active = False
  2815. if dist <= self.npcs[starty][startx].inner_view_range and self.npcs[starty][startx].active == False:
  2816. self.npcs[starty][startx].active = True
  2817. if dist > self.npcs[starty][startx].outer_view_range and self.npcs[starty][startx].active == True:
  2818. self.npcs[starty][startx].active = False
  2819. if self.npcs[starty][startx].active == False:
  2820. return False
  2821. else:
  2822. return True
  2823. #uvector = (vector[0]/dist,vector[1]/dist)
  2824. #c = 0
  2825. #run = True
  2826. #while run:
  2827. # x = int(round(startx+(c*uvector[0]),0))
  2828. # y = int(round(starty+(c*uvector[1]),0))
  2829. #screen.write_hit_matrix(x,y,15)
  2830. # if x < 0 or x > max_map_size or y < 0 or y > max_map_size:
  2831. # return False #only to be sure
  2832. #
  2833. # if x == endx and y == endy:
  2834. # return True
  2835. #
  2836. # if self.tilemap[y][x].transparency == False:
  2837. # return False
  2838. # c += 1
  2839. except:
  2840. return False
  2841. def set_round_frame(self,tile,radius):
  2842. center = int(max_map_size/2)
  2843. for y in range(0,max_map_size):
  2844. for x in range(0,max_map_size):
  2845. range_x = x-center
  2846. range_y = y-center
  2847. if ((range_x**2+range_y**2)**0.5) > radius:
  2848. self.tilemap[y][x] = tile
  2849. def set_music(self,day,night,change_original=False):
  2850. if day != None:
  2851. self.music_day = day
  2852. if change_original == True:
  2853. self.music_day_original = day
  2854. if night != None:
  2855. self.music_night = night
  2856. if change_original == True:
  2857. self.music_night_original = night
  2858. def drunken_finder(self,startx,starty,tile):
  2859. x = startx
  2860. y = starty
  2861. run = True
  2862. while run:
  2863. direction = random.randint(0,3)
  2864. if direction == 0:
  2865. y -= 1
  2866. elif direction == 1:
  2867. x += 1
  2868. elif direction == 2:
  2869. y += 1
  2870. else:
  2871. x -= 1
  2872. if self.tilemap[y][x].techID == tile.techID:
  2873. run = False
  2874. return (x,y)
  2875. def drunken_walker(self,startx,starty,tile_replace,num_replace):
  2876. num = 1
  2877. x = startx
  2878. y = starty
  2879. self.tilemap[y][x] = tile_replace
  2880. while num < num_replace:
  2881. #step 0: get possible directions
  2882. dir_list = []
  2883. for n in range(-1,2):
  2884. if x+n < max_map_size-2 and x+n > 2:
  2885. if x+n < max_map_size-7 and x+n > 7:
  2886. count = 5
  2887. else:
  2888. count = min((max_map_size-2)-(x+n),(x+n),3)
  2889. count = max(count,1)#only to be sure count < 1
  2890. for c in range(0,count):
  2891. dir_list.append([x+n,y])
  2892. if y+n < max_map_size-2 and y+n > 2:
  2893. if y+n < max_map_size-7 and y+n > 7:
  2894. count = 5
  2895. else:
  2896. count = min((max_map_size-2)-(y+n),(y+n),3)
  2897. count = max(count,1)#only to be sure count < 1
  2898. for c in range(0,count):
  2899. dir_list.append([x,y+n])
  2900. #step 1: set tile new tile
  2901. ran = random.randint(0,len(dir_list)-1)
  2902. x = dir_list[ran][0]
  2903. y = dir_list[ran][1]
  2904. if self.tilemap[y][x].techID != tile_replace.techID:
  2905. self.tilemap[y][x] = tile_replace
  2906. num += 1
  2907. def floating(self,startx,starty,tile_fill,tile_border):
  2908. #its important to use a tile_fill that isn't on the map and a tile_border that is on the map
  2909. run = True
  2910. self.tilemap[starty][startx] = deepcopy(tile_fill)
  2911. while run:
  2912. count = 0
  2913. for y in range(0,max_map_size):
  2914. for x in range(0,max_map_size):
  2915. if self.tilemap[y][x].techID == tile_fill.techID:
  2916. for yy in range(y-1,y+2):
  2917. for xx in range(x-1,x+2):
  2918. try:
  2919. if self.tilemap[yy][xx].techID != tile_border.techID and self.tilemap[yy][xx].techID != tile_fill.techID:
  2920. self.tilemap[yy][xx] = deepcopy(tile_fill)
  2921. count += 1
  2922. except:
  2923. None
  2924. if count == 0:
  2925. run = False
  2926. def float_civilisation(self,start_x,start_y):
  2927. tm = []
  2928. for y in range(0,max_map_size):
  2929. tm.append([])
  2930. for x in range(0,max_map_size):
  2931. tm[y].append(0)
  2932. tm[start_y][start_x] = 1
  2933. run = True
  2934. total_count = 1
  2935. while run:
  2936. count = 0
  2937. for yy in range(0,max_map_size):
  2938. for xx in range(0,max_map_size):
  2939. if tm[yy][xx] == 1:
  2940. for yyy in range(yy-1,yy+2):
  2941. for xxx in range(xx-1,xx+2):
  2942. try:
  2943. if tm[yyy][xxx] == 0 and self.tilemap[yyy][xxx].move_group == 'soil' and self.tilemap[yyy][xxx].civilisation == True:
  2944. tm[yyy][xxx] = 1
  2945. count += 1
  2946. total_count += 1
  2947. elif self.tilemap[yyy][xxx].civilisation == False:
  2948. return 0
  2949. except:
  2950. None
  2951. if count == 0:
  2952. run = False
  2953. return total_count
  2954. def float_building_shape(self,start_x,start_y):
  2955. help_map = []
  2956. for i in range(0,max_map_size):
  2957. help_map.append([])
  2958. for j in range(0,max_map_size):
  2959. help_map[i].append(0)
  2960. if self.tilemap[start_y][start_x].civilisation == True:
  2961. help_map[start_y][start_x] = 1
  2962. else:
  2963. return help_map
  2964. run = True
  2965. while run:
  2966. count = 0
  2967. for y in range(0,max_map_size):
  2968. for x in range(0,max_map_size):
  2969. if help_map[y][x] == 1:
  2970. for yy in range(y-1,y+2):
  2971. for xx in range(x-1,x+2):
  2972. if self.tilemap[yy][xx].civilisation == True and help_map[yy][xx] == 0:
  2973. help_map[yy][xx] = 1
  2974. count += 1
  2975. if count == 0:
  2976. run = False
  2977. return help_map
  2978. def get_quarter_size(self,startx,starty):
  2979. #this funktion gives back a tulpel with the width and height of a quarter made out of the same tile like the start position
  2980. techID = self.tilemap[starty][startx].techID
  2981. q_width = 0
  2982. q_height = 0
  2983. run_w = True
  2984. run_h = True
  2985. while run_w:
  2986. if self.tilemap[starty][startx+q_width].techID == techID:
  2987. q_width += 1
  2988. else:
  2989. run_w = False
  2990. while run_h:
  2991. if self.tilemap[starty+q_height][startx].techID == techID:
  2992. q_height += 1
  2993. else:
  2994. run_h = False
  2995. return (q_width,q_height)
  2996. def set_frame(self,tile):
  2997. for y in range (0,max_map_size):
  2998. for x in range (0,max_map_size):
  2999. if x == 0 or x == max_map_size-1 or y == 0 or y == max_map_size-1:
  3000. self.tilemap[y][x] = tile
  3001. def cut(self, minx, maxx, miny, maxy, replace):
  3002. #everything that is not between min and mx is replaced abainst a tile
  3003. for y in range (0,max_map_size):
  3004. for x in range (0,max_map_size):
  3005. if x < minx or x > maxx or y < miny or y > maxy:
  3006. self.tilemap[y][x] = replace
  3007. def imp(self, start_x, start_y, replace_inner, replace_outer, step_min, step_max, circles, replace_except=None): #dig random caves
  3008. #was made to generate random caves but dosn't pleased me. maybe this can be used for mazes.(unused atm)
  3009. x = start_x
  3010. y = start_y
  3011. for l in range (0,circles):
  3012. run = True
  3013. while run:
  3014. direction = random.randint(0,3)
  3015. move_x = 0
  3016. move_y = 0
  3017. if direction == 0:
  3018. move_y = -1
  3019. elif direction == 1:
  3020. move_x = 1
  3021. elif direction == 2:
  3022. move_y = 1
  3023. else:
  3024. move_x= -1
  3025. length = random.randint(step_min, step_max)
  3026. for m in range (0,length):
  3027. x = x + move_x
  3028. y = y + move_y
  3029. if x <= 1 or x >= 78 or y <= 1 or y >= 78:
  3030. break
  3031. run = False
  3032. self.tilemap[y][x] = replace_inner
  3033. for b in range (-1,2):
  3034. for a in range (-1,2):
  3035. if self.tilemap[y+a][x+b] != replace_outer and self.tilemap[y+a][x+b] != replace_inner and self.tilemap[y+a][x+b] != replace_except:
  3036. self.tilemap[y+a][x+b] = replace_outer
  3037. run = False
  3038. def imp_connect(self,xpos,ypos,replace_inner,replace_except=None,except_replacer=None,style='straight'): #conects two or more points
  3039. for a in range (0,len(ypos)-1):
  3040. for b in range(0,len(xpos)-1):
  3041. y = ypos[a]
  3042. x = xpos[b]
  3043. go = True
  3044. direction = 0 #needed for natural ways. jumps between 0 and 1
  3045. while go:
  3046. try:
  3047. y_goal = ypos[a+1]
  3048. x_goal = xpos[b+1]
  3049. except:
  3050. y_goal = ypos[0]
  3051. x_goal = xpos[0]
  3052. if x == x_goal and y == y_goal:
  3053. go = False
  3054. if x_goal - x < 0: #find out if you need to go right or left
  3055. x_direction = -1
  3056. else:
  3057. x_direction = 1
  3058. if y_goal - y < 0: #find out if you need to go up or down
  3059. y_direction = -1
  3060. else:
  3061. y_direction = 1
  3062. if style == 'straight':
  3063. if x != x_goal:
  3064. x = x + x_direction
  3065. if self.tilemap[y][x] != replace_except:
  3066. self.tilemap[y][x] = replace_inner
  3067. elif self.tilemap[y][x] == replace_except:
  3068. self.tilemap[y][x] = except_replacer
  3069. elif y != y_goal:
  3070. y = y + y_direction
  3071. if self.tilemap[y][x] != replace_except:
  3072. self.tilemap[y][x] = replace_inner
  3073. elif self.tilemap[y][x] == replace_except:
  3074. self.tilemap[y][x] = except_replacer
  3075. elif style == 'natural':
  3076. if x != x_goal and direction == 0:
  3077. x = x + x_direction
  3078. if self.tilemap[y][x] != replace_except:
  3079. self.tilemap[y][x] = replace_inner
  3080. elif self.tilemap[y][x] == replace_except:
  3081. self.tilemap[y][x] = except_replacer
  3082. elif y != y_goal and direction == 1:
  3083. y = y + y_direction
  3084. if self.tilemap[y][x] != replace_except:
  3085. self.tilemap[y][x] = replace_inner
  3086. elif self.tilemap[y][x] == replace_except:
  3087. self.tilemap[y][x] = except_replacer
  3088. if direction == 0:
  3089. direction = 1
  3090. elif direction == 1:
  3091. direction = 0
  3092. def spawn_monsters(self,depth):
  3093. #This function spawns monsters on the map
  3094. if self.map_type == 'elfish_fortress':
  3095. monster_max = 0
  3096. for y in range(0,max_map_size):
  3097. for x in range(0,max_map_size):
  3098. if self.tilemap[y][x].techID == tl.tlist['functional'][8].techID:#this is a bed
  3099. monster_max += 1
  3100. else:
  3101. monster_max = (max_map_size*max_map_size)/30
  3102. monster_max = int(monster_max * self.monster_num)
  3103. if self.map_type == 'grot':
  3104. spawnpoints = self.find_all_moveable(ignore_water = False, ignore_no_spawn = False)
  3105. else:
  3106. spawnpoints = self.find_all_moveable(ignore_no_spawn = False)
  3107. del_list = []
  3108. monster_count = self.monster_count
  3109. for i in range (0,len(spawnpoints)):
  3110. if self.npcs[spawnpoints[i][1]][spawnpoints[i][0]] != 0: #there is a monster here
  3111. spawnpoints[i] = 'del'
  3112. #monster_count += 1#count the monsters that are already on the map
  3113. newlist = []
  3114. for k in spawnpoints:
  3115. if k != 'del':
  3116. newlist.append(k)
  3117. spawnpoints = newlist
  3118. monster_max -= monster_count
  3119. if monster_max > len(spawnpoints):
  3120. monster_max = len(spawnpoints)
  3121. for k in range(0,monster_max):
  3122. ran = random.randint(0,len(ml.mlist[self.map_type])-1)
  3123. ran2 = random.randint(0,len(spawnpoints)-1)
  3124. ran3 = random.randint(0,len(ml.mlist['civilian'])-1)
  3125. self.npcs[spawnpoints[ran2][1]][spawnpoints[ran2][0]] = deepcopy(ml.mlist[self.map_type][ran])#deepcopy is used that every monster on the map is saved separate
  3126. self.set_monster_strength(spawnpoints[ran2][0],spawnpoints[ran2][1],depth)
  3127. self.monster_count += 1
  3128. if self.no_monster_respawn == False:
  3129. self.countdowns.append(countdown('spawner',spawnpoints[ran2][1],spawnpoints[ran2][0],random.randint(5,60)))
  3130. try:
  3131. if player.difficulty == 4:
  3132. self.npcs[spawnpoints[ran2][1]][spawnpoints[ran2][0]].AI_style = 'ignore'
  3133. except:
  3134. None
  3135. #set monsters personal_id
  3136. self.npcs[spawnpoints[ran2][1]][spawnpoints[ran2][0]].personal_id = str(self.npcs[spawnpoints[ran2][1]][spawnpoints[ran2][0]].techID)+'_'+str(spawnpoints[ran2][0])+'_'+str(spawnpoints[ran2][1])+'_'+str(random.randint(0,9999))
  3137. #set monster groups
  3138. self.spawn_monster_groups(ml.mlist['kobold'][0],ml.mlist['kobold'][1],9)#kobolds
  3139. def set_monster_strength(self,x,y,z,preset_lvl=None,lvl_bonus=0):
  3140. if self.npcs[y][x] != 0:
  3141. old_lvl = self.npcs[y][x].lvl
  3142. ran = random.randint(1,3)
  3143. if Time_ready == True:
  3144. if player.difficulty == 3:
  3145. base_lvl = 25
  3146. elif player.difficulty == 2:
  3147. base_lvl = 20
  3148. elif player.difficulty == 1:
  3149. base_lvl = 15
  3150. elif player.difficulty == 0:
  3151. base_lvl = 10
  3152. else:
  3153. base_lvl = 0
  3154. time_coeff = int(base_lvl*((time.year-1)*28*12 + time.day_total)/150) #base_lvl levels each 150 days of gameplay #
  3155. else:
  3156. time_coeff = 0
  3157. if self.npcs[y][x].techID == ml.mlist['overworld'][0] or self.npcs[y][x].techID == ml.mlist['angry_monster'][2]: #this is a dryade
  3158. try:
  3159. time_coeff = player.lvl
  3160. except:
  3161. None
  3162. monster_lvl = z + ran + self.monster_plus + time_coeff
  3163. if monster_lvl >= old_lvl and old_lvl > 0:
  3164. try:
  3165. screen.write_hit_matrix(x,y,12) #render monster_lvl_up
  3166. except:
  3167. None
  3168. if preset_lvl != None:
  3169. self.npcs[y][x].lvl = preset_lvl
  3170. else:
  3171. self.npcs[y][x].lvl = monster_lvl
  3172. self.npcs[y][x].lvl += lvl_bonus
  3173. attribute_list =[]
  3174. al = ('p_strength','p_defense','m_strength','m_defense','health')
  3175. for c in range(0,5):
  3176. if self.npcs[y][x].attribute_prev[c] > 0:
  3177. for h in range(0,self.npcs[y][x].attribute_prev[c]):
  3178. attribute_list.append(al[c])
  3179. for i in range(0,self.npcs[y][x].lvl):
  3180. choice = attribute_list[random.randint(0,len(attribute_list)-1)]
  3181. if choice == 'p_strength':
  3182. self.npcs[y][x].basic_attribute.p_strength +=3
  3183. elif choice == 'p_defense':
  3184. self.npcs[y][x].basic_attribute.p_defense +=3
  3185. elif choice == 'm_strength':
  3186. self.npcs[y][x].basic_attribute.m_strength +=3
  3187. elif choice == 'm_defense':
  3188. self.npcs[y][x].basic_attribute.m_defense +=3
  3189. elif choice == 'health':
  3190. self.npcs[y][x].basic_attribute.max_lp +=1
  3191. self.npcs[y][x].lp = self.npcs[y][x].basic_attribute.max_lp
  3192. if old_lvl == 0:
  3193. el = [['spear','sword','axe','hammer'],['rune','wand','rune staff','artefact'],['armor','armor'],['necklace','amulet','talisman'],['ring','ring']]
  3194. e_nr = 0
  3195. for q in range(0,len(el)-1):
  3196. ran = random.randint(0,len(el[q])-1)
  3197. if self.npcs[y][x].worn_equipment[q] == 1:
  3198. help_equipment = item_wear(el[q][ran],random.randint(0,min((z*3),21)),random.randint(-2,2))
  3199. self.npcs[y][x].basic_attribute.p_strength += help_equipment.attribute.p_strength
  3200. self.npcs[y][x].basic_attribute.p_defense += help_equipment.attribute.p_defense
  3201. self.npcs[y][x].basic_attribute.m_strength += help_equipment.attribute.m_strength
  3202. self.npcs[y][x].basic_attribute.m_defense += help_equipment.attribute.m_defense
  3203. self.npcs[y][x].basic_attribute.luck += help_equipment.attribute.luck
  3204. if 'cattle' in self.npcs[y][x].properties:
  3205. self.npcs[y][x].basic_attribute.max_lp = 1
  3206. self.npcs[y][x].lp = self.npcs[y][x].basic_attribute.max_lp
  3207. self.npcs[y][x].lp = self.npcs[y][x].basic_attribute.p_defense = 1
  3208. self.npcs[y][x].lp = self.npcs[y][x].basic_attribute.m_defense = 1
  3209. if 'pet0' in self.npcs[y][x].properties:
  3210. self.npcs[y][x].basic_attribute.max_lp = 5
  3211. if 'pet1' in self.npcs[y][x].properties:
  3212. self.npcs[y][x].basic_attribute.max_lp = 10
  3213. if 'pet2' in self.npcs[y][x].properties:
  3214. self.npcs[y][x].basic_attribute.max_lp = 15
  3215. if 'npc' in self.npcs[y][x].properties:
  3216. self.npcs[y][x].basic_attribute.max_lp = 10
  3217. def make_vault(self,on_tile,depth):
  3218. run = True
  3219. while run:
  3220. pos = self.find_any(on_tile)
  3221. test = True
  3222. orientation = random.randint(0,3)#0:north, 1:east, 2:south, 3:west
  3223. try:
  3224. if pos[0] < 6 or pos[0] > max_map_size-6 or pos[1] < 6 or pos[1] > max_map_size-6:
  3225. test = False
  3226. if orientation == 0:
  3227. x_offset = -2
  3228. y_offset = random.randint(-1,1)
  3229. elif orientation == 1:
  3230. x_offset = random.randint(-1,1)
  3231. y_offset = -2
  3232. elif orientation == 2:
  3233. x_offset = 2
  3234. y_offste = random.randint(-1,1)
  3235. else:
  3236. x_offset = random.randint(-1,1)
  3237. y_offset = 2
  3238. for ty in range(pos[1]+y_offset-1,pos[1]+y_offset+6):
  3239. for tx in range(pos[0]+x_offset-1,pos[0]+x_offset+6):
  3240. if self.tilemap[ty][tx].techID == tl.tlist['dungeon'][0].techID:
  3241. test = False
  3242. elif self.tilemap[ty][tx].techID == tl.tlist['dungeon'][6].techID:
  3243. test = False
  3244. elif self.tilemap[ty][tx].techID == tl.tlist['dungeon'][9].techID:
  3245. test = False
  3246. elif self.tilemap[ty][tx].techID == tl.tlist['functional'][2].techID:
  3247. test = False
  3248. except:
  3249. test = False
  3250. if test:
  3251. run = False
  3252. for yy in range(pos[1]+y_offset-2,pos[1]+y_offset+3):
  3253. for xx in range(pos[0]+x_offset-2,pos[0]+x_offset+3):
  3254. if xx == pos[0]+x_offset-2 or xx == pos[0]+x_offset+2 or yy == pos[1]+y_offset-2 or yy == pos[1]+y_offset+2:
  3255. self.tilemap[yy][xx] = deepcopy(tl.tlist['dungeon'][9])
  3256. self.tilemap[yy][xx].no_spawn = True
  3257. else:
  3258. self.tilemap[yy][xx] = deepcopy(tl.tlist['dungeon'][0])
  3259. self.tilemap[yy][xx].no_spawn = True
  3260. make_loot = True # if make_loot is set on False no gems or ore will spawn inside the vault
  3261. vault_center_x = pos[0]+x_offset
  3262. vault_center_y = pos[1]+y_offset
  3263. door_pos = self.drunken_finder(vault_center_x,vault_center_y,tl.tlist['dungeon'][9])
  3264. self.tilemap[door_pos[1]][door_pos[0]] = deepcopy(tl.tlist['dungeon'][6])
  3265. self.tilemap[door_pos[1]][door_pos[0]].no_spawn = True
  3266. vault_type = random.randint(0,4)
  3267. #vault_type = 4
  3268. if vault_type == 0: #Libary
  3269. replace = self.tilemap[vault_center_y][vault_center_x]
  3270. self.tilemap[vault_center_y][vault_center_x] = deepcopy(tl.tlist['functional'][19])#set a bookshelf
  3271. self.tilemap[vault_center_y][vault_center_x].replace = replace
  3272. self.tilemap[vault_center_y][vault_center_x].no_spawn = True
  3273. replace = self.tilemap[vault_center_y+1][vault_center_x]
  3274. self.tilemap[vault_center_y+1][vault_center_x] = deepcopy(tl.tlist['functional'][4])#set a chest
  3275. self.tilemap[vault_center_y+1][vault_center_x].replace = replace
  3276. self.tilemap[vault_center_y+1][vault_center_x].no_spawn = True
  3277. num_spellbooks = random.randint(2,3)#fill the chest
  3278. spellbook_list = []
  3279. sb = (il.ilist['misc'][26],il.ilist['misc'][30],il.ilist['misc'][32],il.ilist['misc'][34],il.ilist['misc'][36],il.ilist['misc'][38],il.ilist['misc'][45],il.ilist['misc'][83])
  3280. for i in range(0,num_spellbooks):
  3281. ran = random.randint(0,len(sb)-1)
  3282. spellbook_list.append(sb[ran])
  3283. self.containers[vault_center_y+1][vault_center_x] = container(spellbook_list)
  3284. self.npcs[vault_center_y-1][vault_center_x-1] = deepcopy(ml.mlist['grot'][0]) #
  3285. self.set_monster_strength(vault_center_x-1,vault_center_y-1,depth,lvl_bonus=3) #
  3286. self.npcs[vault_center_y-1][vault_center_x+1] = deepcopy(ml.mlist['grot'][0]) #
  3287. self.set_monster_strength(vault_center_x+1,vault_center_y-1,depth,lvl_bonus=3) #set blue nagas
  3288. self.npcs[vault_center_y+1][vault_center_x-1] = deepcopy(ml.mlist['grot'][0]) #
  3289. self.set_monster_strength(vault_center_x-1,vault_center_y+1,depth,lvl_bonus=3) #
  3290. self.npcs[vault_center_y+1][vault_center_x+1] = deepcopy(ml.mlist['grot'][0]) #
  3291. self.set_monster_strength(vault_center_x+1,vault_center_y+1,depth,lvl_bonus=3) #
  3292. if vault_type == 1: #Slime pit
  3293. replace = self.tilemap[vault_center_y][vault_center_x]
  3294. self.tilemap[vault_center_y][vault_center_x] = deepcopy(tl.tlist['statue'][2])#set a blob statue
  3295. self.tilemap[vault_center_y][vault_center_x].replace = replace
  3296. self.tilemap[vault_center_y][vault_center_x].no_spawn = True
  3297. self.npcs[vault_center_y-1][vault_center_x-1] = deepcopy(ml.mlist['special'][10]) #
  3298. self.set_monster_strength(vault_center_x-1,vault_center_y-1,depth,lvl_bonus=3) #
  3299. self.npcs[vault_center_y-1][vault_center_x+1] = deepcopy(ml.mlist['special'][10]) #
  3300. self.set_monster_strength(vault_center_x+1,vault_center_y-1,depth,lvl_bonus=3) #set giant blobs
  3301. self.npcs[vault_center_y+1][vault_center_x-1] = deepcopy(ml.mlist['special'][10]) #
  3302. self.set_monster_strength(vault_center_x-1,vault_center_y+1,depth,lvl_bonus=3) #
  3303. self.npcs[vault_center_y+1][vault_center_x+1] = deepcopy(ml.mlist['special'][10]) #
  3304. self.set_monster_strength(vault_center_x+1,vault_center_y+1,depth,lvl_bonus=3) #
  3305. if vault_type == 2: #Kobold Lair
  3306. replace = self.tilemap[vault_center_y][vault_center_x]
  3307. self.tilemap[vault_center_y][vault_center_x] = deepcopy(tl.tlist['deco'][9])#set a stony throne
  3308. self.tilemap[vault_center_y][vault_center_x].replace = replace #
  3309. self.tilemap[vault_center_y][vault_center_x].no_spawn = True #
  3310. for posy in range(vault_center_y-1,vault_center_y+2): #
  3311. for posx in range(vault_center_x-1,vault_center_x+2): #set Kobolds
  3312. self.npcs[posy][posx] = deepcopy(ml.mlist['kobold'][1]) #
  3313. self.set_monster_strength(posx,posy,depth,lvl_bonus=3) #
  3314. self.npcs[vault_center_y][vault_center_x] = deepcopy(ml.mlist['kobold'][0]) #set kobold shaman
  3315. self.set_monster_strength(vault_center_x,vault_center_y,depth,lvl_bonus=3) #
  3316. if vault_type == 3: #Bat Cave
  3317. make_loot = False
  3318. for posy in range(vault_center_y-1,vault_center_y+2): #
  3319. for posx in range(vault_center_x-1,vault_center_x+2): #set bats
  3320. self.npcs[posy][posx] = deepcopy(ml.mlist['cave'][2]) #
  3321. self.set_monster_strength(posx,posy,depth) #
  3322. if vault_type == 4: #mimic chamber
  3323. make_loot = False
  3324. ranx = random.randint(-1,1) #
  3325. rany = random.randint(-1,1) #
  3326. replace = self.tilemap[vault_center_y+rany][vault_center_x+ranx] #
  3327. self.tilemap[vault_center_y+rany][vault_center_x+ranx] = deepcopy(tl.tlist['functional'][4])#set a chest
  3328. self.tilemap[vault_center_y+rany][vault_center_x+ranx].replace = replace #
  3329. self.tilemap[vault_center_y+rany][vault_center_x+ranx].no_spawn = True #
  3330. sb = (il.ilist['misc'][26],il.ilist['misc'][30],il.ilist['misc'][32],il.ilist['misc'][34],il.ilist['misc'][36],il.ilist['misc'][38],il.ilist['misc'][45],il.ilist['misc'][83])
  3331. ransb = random.randint(0,len(sb)-1)
  3332. book = sb[ransb]
  3333. pick = item_wear('pickaxe', 20,0)
  3334. axe = item_wear('axe',20,0)
  3335. self.containers[vault_center_y+rany][vault_center_x+ranx] = container([book,axe,pick])#fill chest
  3336. for posy in range(vault_center_y-1,vault_center_y+2): #
  3337. for posx in range(vault_center_x-1,vault_center_x+2): #set sleeping mimics
  3338. if self.tilemap[posy][posx].techID != tl.tlist['functional'][4].techID: #
  3339. self.npcs[posy][posx] = deepcopy(ml.mlist['special'][3]) #
  3340. if make_loot == True:
  3341. for yyy in range(vault_center_y-2,vault_center_y+3):
  3342. for xxx in range(vault_center_x-2,vault_center_x+3):
  3343. if self.tilemap[yyy][xxx].techID == tl.tlist['dungeon'][0].techID:
  3344. ran2 = random.randint(0,2)
  3345. replace = self.tilemap[yyy][xxx]
  3346. if ran2 > 1:
  3347. self.tilemap[yyy][xxx] = deepcopy(tl.tlist['misc'][9])#set gem
  3348. self.tilemap[yyy][xxx].no_spawn = True
  3349. else:
  3350. self.tilemap[yyy][xxx] = deepcopy(tl.tlist['misc'][11])#set ore
  3351. self.tilemap[yyy][xxx].no_spawn = True
  3352. self.tilemap[yyy][xxx].replace = replace
  3353. #print('Made vault at: '+str(pos[0])+','+str(pos[1])+' Type:'+str(vault_type))
  3354. ####go on here
  3355. def make_orc_cave(self,on_tile):
  3356. run = True
  3357. while run:
  3358. pos = self.find_any(on_tile)
  3359. test = True
  3360. try:
  3361. for ty in range(pos[1]-2,pos[1]+3):
  3362. for tx in range(pos[0]-2,pos[0]+3):
  3363. if self.tilemap[ty][tx].techID == tl.tlist['misc'][16].techID:
  3364. test = False
  3365. elif self.tilemap[ty][tx].techID == tl.tlist['mine'][0].techID:
  3366. test = False
  3367. elif self.tilemap[ty][tx].techID == tl.tlist['dungeon'][3].techID:
  3368. test = False
  3369. elif self.tilemap[ty][tx].techID == tl.tlist['misc'][12].techID:
  3370. test = False
  3371. except:
  3372. test = False
  3373. if ((pos[0]-(max_map_size/2))**2+(pos[1]-(max_map_size/2))**2)**0.5 > 10:
  3374. if pos[0] > 5 and pos[0] < max_map_size-5 and pos[1] > 5 and pos[1] < max_map_size-5 and test == True:
  3375. run = False
  3376. for y in range(pos[1]-2,pos[1]+3):
  3377. for x in range(pos[0]-2,pos[0]+3):
  3378. self.tilemap[y][x] = tl.tlist['misc'][16] #fill with solid orcish wall
  3379. for y in range(pos[1]-1,pos[1]+2):
  3380. for x in range(pos[0]-1,pos[0]+2):
  3381. self.tilemap[y][x] = tl.tlist['mine'][0] #fill inner with orcish mine floor
  3382. if x != pos[0] or y != pos[1]:
  3383. self.npcs[y][x] = deepcopy(ml.mlist['orc'][random.randint(0,len(ml.mlist['orc'])-1)]) #
  3384. else: #
  3385. self.npcs[y][x] = deepcopy(ml.mlist['orcish_mines'][1]) #
  3386. self.set_monster_strength(x,y,1) #generate orcs
  3387. self.countdowns.append(countdown('orc_spawner',x,y,random.randint(5,60))) #
  3388. self.tilemap[pos[1]-2][pos[0]] = deepcopy(tl.tlist['dungeon'][3])#
  3389. self.tilemap[pos[1]+2][pos[0]] = deepcopy(tl.tlist['dungeon'][3])# make dungeon doors
  3390. self.tilemap[pos[1]][pos[0]-2] = deepcopy(tl.tlist['dungeon'][3])#
  3391. self.tilemap[pos[1]][pos[0]+2] = deepcopy(tl.tlist['dungeon'][3])#
  3392. self.tilemap[pos[1]-2][pos[0]-2] = deepcopy(tl.tlist['misc'][12])#
  3393. self.tilemap[pos[1]-2][pos[0]-2].replace = deepcopy(on_tile) #
  3394. self.tilemap[pos[1]-2][pos[0]+2] = deepcopy(tl.tlist['misc'][12])#
  3395. self.tilemap[pos[1]-2][pos[0]+2].replace = deepcopy(on_tile) # add orc deko to the connors
  3396. self.tilemap[pos[1]+2][pos[0]-2] = deepcopy(tl.tlist['misc'][12])#
  3397. self.tilemap[pos[1]+2][pos[0]-2].replace = deepcopy(on_tile) #
  3398. self.tilemap[pos[1]+2][pos[0]+2] = deepcopy(tl.tlist['misc'][12])#
  3399. self.tilemap[pos[1]+2][pos[0]+2].replace = deepcopy(on_tile) #
  3400. self.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['misc'][18])#set a crystal orb
  3401. def AI_move(self):
  3402. #This function moves all monsters that are 7 or less fields away from the player.
  3403. #It dosn't move all monsters to save performance
  3404. #ymin = player.pos[1]-7
  3405. #if ymin < 0:
  3406. # ymin = 0
  3407. #xmin = player.pos[0]-7
  3408. #if xmin < 0:
  3409. # xmin = 0
  3410. #ymax = player.pos[1]+8
  3411. #if ymax > max_map_size:
  3412. # ymax = max_map_size
  3413. #xmax = player.pos[0]+8
  3414. #if xmax > max_map_size:
  3415. # xmax = max_map_size
  3416. xmin = 0
  3417. ymin = 0
  3418. xmax = max_map_size
  3419. ymax = max_map_size
  3420. for y in range (ymin,ymax):#reset the move_done switches
  3421. for x in range (xmin,xmax):
  3422. if self.npcs[y][x] != 0:
  3423. if self.npcs[y][x].lp > 0:
  3424. self.npcs[y][x].move_done = 0
  3425. else:
  3426. test = False
  3427. while test == False:
  3428. test = self.monster_die(x,y)
  3429. for y in range (ymin,ymax):
  3430. for x in range (xmin,xmax):
  3431. if self.npcs[y][x] != 0 and self.npcs[y][x].move_done == 0:#if there is a monster at this place
  3432. #-2. get AI_style
  3433. AI_style = self.npcs[y][x].AI_style
  3434. #-1. remove blind
  3435. if 'blind' in self.npcs[y][x].properties:
  3436. rand = random.randint(0,9)
  3437. if rand < 2:
  3438. for i in range(0,len(self.npcs[y][x].properties)):
  3439. if self.npcs[y][x].properties[i] == 'blind':
  3440. p = i
  3441. try:
  3442. del self.npcs[y][x].properties[p]
  3443. except:
  3444. None
  3445. #0. Get LoS
  3446. los = self.check_los(x,y,player.pos[0],player.pos[1])
  3447. if 'blind' in self.npcs[y][x].properties:
  3448. los = False
  3449. if los == True:
  3450. self.npcs[y][x].last_known_player_pos = (player.pos[0],player.pos[1])
  3451. if player.buffs.get_buff('invisible') > 0:
  3452. los = False
  3453. if self.npcs[y][x].last_known_player_pos != 'Unknown':
  3454. if x == self.npcs[y][x].last_known_player_pos[0] and y == self.npcs[y][x].last_known_player_pos[1]:
  3455. self.npcs[y][x].last_known_player_pos = 'Unknown'
  3456. if player.buffs.get_buff('invisible') > 0 or 'blind' in self.npcs[y][x].properties:
  3457. self.npcs[y][x].last_known_player_pos = 'Unknown'
  3458. #I. Get possible fields for a move
  3459. moves = [(x,y)]
  3460. yy = (-1,0,0,1)
  3461. xx = (0,-1,1,0)
  3462. for i in range (0,4):
  3463. try:
  3464. monster_move_groups = self.npcs[y][x].move_groups
  3465. tile_move_group = self.tilemap[y+yy[i]][x+xx[i]].move_group
  3466. move_group_check = tile_move_group in monster_move_groups
  3467. if self.npcs[y+yy[i]][x+xx[i]] == 0:
  3468. npc = False
  3469. else:
  3470. npc = True
  3471. if self.tilemap[y+yy[i]][x+xx[i]].techID == tl.tlist['functional'][1].techID or self.tilemap[y+yy[i]][x+xx[i]].techID == tl.tlist['functional'][2].techID: #this is a stair up/down
  3472. stair = True
  3473. else:
  3474. stair = False
  3475. if x + xx[i] == player.pos[0] and y + yy[i] == player.pos[1]:
  3476. playerpos = True
  3477. else:
  3478. playerpos = False
  3479. if move_group_check == True and npc == False and stair == False and playerpos == False:
  3480. moves.append((x+xx[i],y+yy[i]))
  3481. except:
  3482. print('Debug:Error')
  3483. #II. Find out which possible move leads to which distance between monster and player
  3484. distances = []
  3485. for j in range (0,len(moves)):
  3486. if self.npcs[y][x].last_known_player_pos != 'Unknown':
  3487. a = self.npcs[y][x].last_known_player_pos[0] - moves[j][0]
  3488. b = self.npcs[y][x].last_known_player_pos[1] - moves[j][1]
  3489. else:
  3490. a = 100
  3491. b = 100
  3492. c = (a**2 + b**2)**0.5 # this is just the good old pythagoras (c² = a² + b²)
  3493. distances.append(c)
  3494. #III. Choose the right move (or special action)
  3495. do_move = 'foo'
  3496. if AI_style == 'hostile' and los == False:# and self.npcs[y][x].last_known_player_pos == 'Unknown':
  3497. AI_style = 'ignore'
  3498. if AI_style == 'hostile':
  3499. comp = False
  3500. for yy in range(y-1,y+2):
  3501. if self.npcs[yy][x] != 0 and self.npcs[yy][x].AI_style == 'company':
  3502. comp = [x,yy]
  3503. for xx in range(x-1,x+2):
  3504. if self.npcs[y][xx] != 0 and self.npcs[y][xx].AI_style == 'company':
  3505. comp = [xx,y]
  3506. if comp != False and not 'blind' in self.npcs[y][x].properties:
  3507. ran = random.randint(0,99)
  3508. if ran < 40:
  3509. self.npcs[y][x].move_done = 1
  3510. mes = self.npcs[y][x].name + ' [hurts] ' + self.npcs[comp[1]][comp[0]].name
  3511. message.add(mes)
  3512. screen.write_hit_matrix(comp[0],comp[1],4)
  3513. sfx.play('hit')
  3514. player.pet_lp -= 1
  3515. if player.pet_lp < 1:
  3516. self.npcs[comp[1]][comp[0]].relation = int(self.npcs[comp[1]][comp[0]].relation*0.8)
  3517. return_done = False
  3518. for yyy in range(0,max_map_size):
  3519. for xxx in range(0,max_map_size):
  3520. if world.maplist[0]['elysium_0_0'].tilemap[yyy][xxx].techID == tl.tlist['sanctuary'][4].techID and world.maplist[0]['elysium_0_0'].npcs[yyy][xxx] == 0 and return_done == False:
  3521. string = self.npcs[comp[1]][comp[0]].name + ' returns home.'
  3522. message.add(string)
  3523. screen.write_hit_matrix(comp[0],comp[1],7)
  3524. self.npcs[comp[1]][comp[0]].AI_style = 'ignore'
  3525. world.maplist[0]['elysium_0_0'].npcs[yyy][xxx] = deepcopy(self.npcs[comp[1]][comp[0]])
  3526. self.npcs[comp[1]][comp[0]] = 0
  3527. player.pet_pos = False
  3528. player.pet_on_map = False
  3529. return_done = True
  3530. ability_keys = self.npcs[y][x].ability.keys()
  3531. if self.npcs[y][x].lp < self.npcs[y][x].basic_attribute.max_lp/2 and player.lp > player.attribute.max_lp/2 and distances[0] < 3 and self.npcs[y][x].num_special > 0 :#this is a defensive situation for the monster
  3532. if 'def_teleport' in ability_keys:
  3533. ran = random.randint(0,99)
  3534. if ran < self.npcs[y][x].ability['def_teleport'] and self.npcs[y][x].move_done != 1:
  3535. moves = self.find_all_moveable(ignore_player_pos = False)
  3536. if moves != False:
  3537. if len(moves) == 1:
  3538. pos_num = 0
  3539. else:
  3540. pos_num = random.randint(0,len(moves)-1)
  3541. self.npcs[y][x].move_done = 1
  3542. self.npcs[y][x].num_special -= 1
  3543. tp_string = 'A ' + self.npcs[y][x].name + ' teleports.'
  3544. message.add(tp_string)
  3545. screen.write_hit_matrix(x,y,7)
  3546. sfx.play('teleport')
  3547. self.npcs[moves[pos_num][1]][moves[pos_num][0]] = self.npcs[y][x]
  3548. self.npcs[y][x] = 0
  3549. if 'def_flee' in ability_keys:
  3550. ran = random.randint(0,99)
  3551. if self.npcs[y][x] != 0:
  3552. if ran < self.npcs[y][x].ability['def_flee'] and self.npcs[y][x].move_done != 1 and self.npcs[y][x].lp < self.npcs[y][x].basic_attribute.max_lp:
  3553. flee_string = 'A ' + self.npcs[y][x].name + ' turns to flee.'
  3554. message.add(flee_string)
  3555. self.npcs[y][x].AI_style = 'flee'
  3556. self.npcs[y][x].move_done = 1
  3557. self.npcs[y][x].num_special -= 1
  3558. if 'def_potion' in ability_keys:
  3559. ran = random.randint(0,99)
  3560. if ran < self.npcs[y][x].ability['def_potion'] and self.npcs[y][x].move_done != 1:
  3561. if self.npcs[y][x].lp < self.npcs[y][x].basic_attribute.max_lp:
  3562. potion_string = 'A ' + self.npcs[y][x].name + ' quaffes a potion of healing.'
  3563. message.add(potion_string)
  3564. screen.write_hit_matrix(x,y,6)
  3565. lp = min(self.npcs[y][x].basic_attribute.max_lp, self.npcs[y][x].lp+7)
  3566. self.npcs[y][x].lp = lp
  3567. sfx.play('drink')
  3568. self.npcs[y][x].move_done = 1
  3569. self.npcs[y][x].num_special -= 1
  3570. if self.npcs[y][x] != 0:
  3571. if (distances[0] > 1 or player.buffs.get_buff('invisible') > 0) and self.npcs[y][x].move_done != 1: #moves[0] is always the position of the monster right now, so distances 0 is always it's distance towards the player
  3572. if 'spawn' in ability_keys and distances[0] < 8: #the value of spawn is a tulpel with 2 elements; 0: chance that something is spawned 1: number that determines what is spawned
  3573. ran = random.randint(0,99)
  3574. if ran < self.npcs[y][x].ability['spawn'][0]:
  3575. spawn_kind = self.npcs[y][x].ability['spawn'][1]
  3576. xlist = []
  3577. ylist = []
  3578. for yy in range(y-1,y+2):
  3579. for xx in range(x-1,x+2):
  3580. if self.tilemap[yy][xx].move_group == 'soil' and self.npcs[yy][xx] == 0 and xx != player.pos[0] and yy != player.pos[1]:
  3581. xlist.append(xx)
  3582. ylist.append(yy)
  3583. if len(xlist) == len(ylist) and len(xlist) > 0:
  3584. if len(xlist) > 1:
  3585. num = random.randint(0,len(xlist)-1)
  3586. else:
  3587. num = 0
  3588. if self.npcs[y][x].move_done != 1 and self.npcs[y][x].num_special > 0:
  3589. self.npcs[ylist[num]][xlist[num]] = deepcopy(ml.mlist['special'][spawn_kind]) #all spawnlings must be a part of ml.mlist['special']
  3590. self.npcs[ylist[num]][xlist[num]].personal_id = self.npcs[y][x].personal_id + '_child'
  3591. self.set_monster_strength(xlist[num],ylist[num],player.pos[2])
  3592. mes = 'A ' + self.npcs[y][x].name + ' summons a ' + ml.mlist['special'][spawn_kind].name + '.'
  3593. message.add(mes)
  3594. sfx.play('teleport')
  3595. screen.write_hit_matrix(xlist[num],ylist[num],7)
  3596. self.npcs[y][x].move_done = 1
  3597. self.npcs[y][x].num_special -= 1
  3598. if 'blink' in ability_keys:
  3599. ran = random.randint(0,99)
  3600. if ran < self.npcs[y][x].ability['blink'] and self.npcs[y][x].move_done != 1 and self.npcs[y][x].num_special > 0:
  3601. xlist = []
  3602. ylist = []
  3603. for yy in range(player.pos[1]-3,player.pos[1]+4):
  3604. for xx in range(player.pos[0]-3,player.pos[0]+4):
  3605. if self.tilemap[yy][xx].move_group in self.npcs[y][x].move_groups and self.npcs[yy][xx] == 0:
  3606. if yy != player.pos[1] or xx != player.pos[0]:
  3607. xlist.append(xx)
  3608. ylist.append(yy)
  3609. if len(xlist) != 0:
  3610. try:
  3611. rand = random.randint(0,len(xlist)-1)
  3612. except:
  3613. rand = 0
  3614. screen.write_hit_matrix(x,y,7)
  3615. screen.write_hit_matrix(xlist[rand],ylist[rand],7)
  3616. mes = 'A '+self.npcs[y][x].name+' blinks!'
  3617. message.add(mes)
  3618. self.npcs[ylist[rand]][xlist[rand]] = self.npcs[y][x]
  3619. self.npcs[y][x] = 0
  3620. self.npcs[ylist[rand]][xlist[rand]].num_special -= 1
  3621. self.npcs[ylist[rand]][xlist[rand]].move_done = 1
  3622. if (x == player.pos[0] or y == player.pos[1]) and los == True:
  3623. straight_line = True
  3624. else:
  3625. straight_line = False
  3626. shoot = False
  3627. throw = False
  3628. if 'range_shoot' in ability_keys:
  3629. shoot = True
  3630. elif 'range_throw' in ability_keys:
  3631. throw = True
  3632. if self.npcs[y][x] != 0 and straight_line == True and los == True and (shoot == True or throw == True) and distances[0] < 5:
  3633. #Step 0: Random
  3634. if shoot == True:
  3635. chance = self.npcs[y][x].ability['range_shoot']
  3636. else:
  3637. chance = self.npcs[y][x].ability['range_throw'][0]
  3638. ran = random.randint(0,99)
  3639. if ran < chance and self.npcs[y][x].num_special > 0 and self.npcs[y][x].move_done != 1:
  3640. #Step 1: find the right direction
  3641. if y > player.pos[1]:
  3642. y_dir = -1
  3643. elif y < player.pos[1]:
  3644. y_dir = 1
  3645. else:
  3646. y_dir = 0
  3647. if x > player.pos[0]:
  3648. x_dir = -1
  3649. elif x < player.pos[0]:
  3650. x_dir = 1
  3651. else:
  3652. x_dir = 0
  3653. #Step 2: Check for borders
  3654. run = True
  3655. count = 1
  3656. fire_free = True
  3657. while run:
  3658. cx = x + (count*x_dir)
  3659. cy = y + (count*y_dir)
  3660. if self.tilemap[cy][cx].transparency == False:
  3661. fire_free = False
  3662. run = False
  3663. count +=1
  3664. if cx == player.pos[0] and cy == player.pos[1]:
  3665. run = False
  3666. #Step 3: Fire!
  3667. if fire_free == True:
  3668. run = True
  3669. count = 1
  3670. if 'range_shoot' in ability_keys:
  3671. sfx.play('fire')
  3672. else:
  3673. sfx.play('miss')
  3674. while run:
  3675. xx = x + (count*x_dir)
  3676. yy = y + (count*y_dir)
  3677. if xx != player.pos[0] or yy != player.pos[1]:
  3678. screen.write_hit_matrix(xx,yy,2)
  3679. if self.tilemap[yy][xx].transparency == False:
  3680. screen.write_hit_matrix(player.pos[0],player.pos[1],3)
  3681. if 'range_throw' in ability_keys:
  3682. sfx.play('throw')
  3683. run = False
  3684. else:
  3685. if shoot == True:#----------> go on here!!!!!!!!
  3686. self.npcs[y][x].move_done = 1
  3687. try:
  3688. player.monster_attacks(x,y)
  3689. except:
  3690. None
  3691. elif self.npcs[y][x].ability['range_throw'][1] == 'stone':
  3692. self.npcs[y][x].move_done = 1
  3693. message.add('A '+self.npcs[y][x].name+' throws a stone!')
  3694. chance = 9 - count
  3695. coin = random.randint(0,9)
  3696. if coin < chance:
  3697. sfx.play('hit')
  3698. screen.write_hit_matrix(player.pos[0],player.pos[1],4)
  3699. message.add('The stone hits you.(1 damage)')
  3700. player.lp -= 1
  3701. else:
  3702. sfx.play('throw')
  3703. screen.write_hit_matrix(player.pos[0],player.pos[1],3)
  3704. message.add('The stone misses you.')
  3705. elif self.npcs[y][x].ability['range_throw'][1] == 'dart':
  3706. self.npcs[y][x].move_done = 1
  3707. message.add('A '+self.npcs[y][x].name+' throws a dart!')
  3708. chance = 9 - count
  3709. coin = random.randint(0,9)
  3710. if coin < chance:
  3711. sfx.play('hit')
  3712. screen.write_hit_matrix(player.pos[0],player.pos[1],4)
  3713. message.add('The dart hits you.(2 damage)')
  3714. player.lp -= 2
  3715. else:
  3716. sfx.play('throw')
  3717. screen.write_hit_matrix(player.pos[0],player.pos[1],3)
  3718. message.add('The dart misses you.')
  3719. elif self.npcs[y][x].ability['range_throw'][1] == 'knife':
  3720. self.npcs[y][x].move_done = 1
  3721. message.add('A '+self.npcs[y][x].name+' throws a throwing knife')
  3722. chance = 9 - count
  3723. coin = random.randint(0,9)
  3724. if coin < chance:
  3725. sfx.play('hit')
  3726. screen.write_hit_matrix(player.pos[0],player.pos[1],4)
  3727. message.add('The throwing knife hits you.(3 damage)')
  3728. player.lp -= 3
  3729. else:
  3730. sfx.play('throw')
  3731. screen.write_hit_matrix(player.pos[0],player.pos[1],3)
  3732. message.add('The throwing knife misses you.')
  3733. run = False
  3734. count += 1
  3735. self.npcs[y][x].move_done = 1
  3736. if 'range_throw' in ability_keys:
  3737. self.npcs[y][x].num_special -= 1
  3738. if self.npcs[y][x] != 0 and self.npcs[y][x].move_done == 0:
  3739. if len(moves) > 0:#if no move is possible at least the 'move' of stay still must remain
  3740. good_moves = []
  3741. for k in range (0, len(moves)):
  3742. if player.buffs.get_buff('invisible') == 0:
  3743. if distances[k] <= distances[0]:#if the possible move makes the distance between player and monster smaller
  3744. good_moves.append(moves[k])
  3745. else:
  3746. good_moves = moves
  3747. if 'blind' in self.npcs[y][x].properties or player.buffs.get_buff('invisible') != 0:
  3748. good_moves = moves
  3749. else:
  3750. good_moves = moves
  3751. if len(good_moves) <= 1:
  3752. good_moves = moves
  3753. if len(good_moves) > 1:
  3754. ran = random.randint(0,len(good_moves)-1)
  3755. else:
  3756. ran = 0
  3757. do_move = good_moves[ran]
  3758. else:
  3759. if self.npcs[y][x].move_done == 0 and self.npcs[y][x].last_known_player_pos == (player.pos[0],player.pos[1]) and distances[0] == 1 and los == True:
  3760. #the most important thing about stealing monsters is that their default corps_style has to be 'thief' and their corps_lvl has to be 0. Otherwise they would not work proper.
  3761. if player.inventory.materials.gem > 0 and 'close_steal' in ability_keys:
  3762. ran = random.randint(0,99)
  3763. if ran < self.npcs[y][x].ability['close_steal']:
  3764. player.inventory.materials.gem -= 1
  3765. self.npcs[y][x].corps_lvl += 1
  3766. screen.write_hit_matrix(player.pos[0],player.pos[1],8)
  3767. screen.write_hit_matrix(x,y,9)
  3768. sfx.play('steal')
  3769. steal_string = 'A ' + self.npcs[y][x].name + ' steals a gem from you.'
  3770. message.add(steal_string)
  3771. self.npcs[y][x].move_done = 1#set the move_done switch on
  3772. if self.npcs[y][x].move_done == 0:
  3773. #casting flames
  3774. if 'close_flames' in ability_keys:
  3775. ran = random.randint(0,99)
  3776. if ran < self.npcs[y][x].ability['close_flames'] and self.npcs[y][x].num_special > 0:
  3777. #Step 0: Check if any (other) monsters are near by
  3778. sfx.play('flame')
  3779. monster_num = 0
  3780. for yy in range(y-1,y+2):
  3781. for xx in range(x-1,x+2):
  3782. if self.npcs[yy][xx] != 0:
  3783. monster_num += 1
  3784. if monster_num == 1:#there is no other monster near by
  3785. num_flames = 0
  3786. for yyy in range(y-1,y+2):
  3787. for xxx in range(x-1,x+2):
  3788. if xxx != x or yyy != y:
  3789. if self.tilemap[yyy][xxx].replace == None and self.tilemap[yyy][xxx].move_group != 'solid' and self.tilemap[yyy][xxx].move_group != 'low_liquid' and self.tilemap[yyy][xxx].move_group != 'swim':
  3790. replace = self.tilemap[yyy][xxx]
  3791. self.tilemap[yyy][xxx] = deepcopy(tl.tlist['effect'][4])
  3792. self.tilemap[yyy][xxx].replace = replace
  3793. self.countdowns.append(countdown('flame',xxx,yyy,3))
  3794. num_flames+=1
  3795. if num_flames > 0:
  3796. flame_string = 'A '+ self.npcs[y][x].name + ' casts a flame spell!'
  3797. message.add(flame_string)
  3798. self.npcs[y][x].num_special -= 1
  3799. self.npcs[y][x].move_done = 1
  3800. if self.npcs[y][x].move_done == 0 and self.npcs[y][x].num_special > 0:
  3801. #vampirism
  3802. if 'close_vampirism' in ability_keys:
  3803. ran = random.randint(0,99)
  3804. if ran < self.npcs[y][x].ability['close_vampirism']:
  3805. player.lp -= 1
  3806. self.npcs[y][x].lp += 1
  3807. screen.write_hit_matrix(player.pos[0],player.pos[1],18)
  3808. screen.write_hit_matrix(x,y,19)
  3809. sfx.play('vampire')
  3810. vamp_string = 'A ' + self.npcs[y][x].name +' sucks your blood.'
  3811. message.add(vamp_string)
  3812. self.npcs[y][x].num_special -= 1
  3813. self.npcs[y][x].move_done = 1
  3814. if self.npcs[y][x].move_done == 0 and self.npcs[y][x].num_special > 0:
  3815. #steal items
  3816. if 'close_stealItem' in ability_keys:
  3817. ran = random.randint(0,99)
  3818. if ran < self.npcs[y][x].ability['close_stealItem']:
  3819. #0: Find parent
  3820. parent_pos = False
  3821. parent_id = self.npcs[y][x].personal_id.replace('_child','')
  3822. for yy in range(0,max_map_size):
  3823. for xx in range(0,max_map_size):
  3824. if self.npcs[yy][xx] != 0 and self.npcs[yy][xx].personal_id == parent_id:
  3825. parent_pos = (xx,yy)
  3826. #1: Check Parent Status
  3827. if parent_pos != False:
  3828. if len(self.containers[parent_pos[1]][parent_pos[0]].items) < 7:
  3829. p_check = True
  3830. else:
  3831. p_check = False
  3832. #2: Steal Item
  3833. if p_check == True:
  3834. all_bp = ('Head','Body','Legs','Feet','Hold(R)','Hold(L)','Neck','Axe','Pickaxe','Hand')
  3835. final_bp = ['None',]
  3836. for i in range(0,len(all_bp)-1):
  3837. if player.inventory.wearing[all_bp[i]] != player.inventory.nothing:
  3838. final_bp.append(all_bp[i])
  3839. del final_bp[0]
  3840. if len(final_bp) > 0:
  3841. if len(final_bp) == 1:
  3842. ran = 0
  3843. else:
  3844. ran = random.randint(0,len(final_bp)-1)
  3845. item = player.inventory.wearing[final_bp[ran]]
  3846. player.inventory.wearing[final_bp[ran]] = player.inventory.nothing
  3847. self.containers[parent_pos[1]][parent_pos[0]].items.append(item)
  3848. mes = 'A '+self.npcs[y][x].name+' steals your '+item.name+'!'
  3849. message.add(mes)
  3850. sfx.play('steal')
  3851. screen.write_hit_matrix(player.pos[0],player.pos[1],21)
  3852. screen.write_hit_matrix(parent_pos[0],parent_pos[1],22)
  3853. self.npcs[y][x].lp = 0
  3854. if self.npcs[y][x].move_done == 0 and self.npcs[y][x].num_special > 0:
  3855. #throw explosives
  3856. if 'close_throwExplosive' in ability_keys:
  3857. ran = random.randint(0,99)
  3858. if ran < self.npcs[y][x].ability['close_throwExplosive']:
  3859. positions = []
  3860. for yy in range(player.pos[1]-1,player.pos[1]+2):
  3861. for xx in range(player.pos[0]-1,player.pos[0]+2):
  3862. if self.tilemap[yy][xx].replace == None and self.tilemap[yy][xx].move_group == 'soil' and self.tilemap[yy][xx].use_group == 'None':
  3863. positions.append((xx,yy))
  3864. if len(positions) > 0:
  3865. sfx.play('throw')
  3866. screen.write_hit_matrix(x,y,20)
  3867. ran = random.randint(0,len(positions)-1)
  3868. pos = positions[ran]
  3869. screen.write_hit_matrix(pos[0],pos[1],16)
  3870. coin = random.randint(0,3)
  3871. if coin == 0:
  3872. message.add('A '+self.npcs[y][x].name+' throws a bomb!')
  3873. replace = self.tilemap[pos[1]][pos[0]]
  3874. self.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['effect'][0])
  3875. self.countdowns.append(countdown('bomb3',pos[0],pos[1],1))
  3876. self.tilemap[pos[1]][pos[0]].replace = replace
  3877. else:
  3878. message.add('A '+self.npcs[y][x].name+' throws an explosive!')
  3879. replace = self.tilemap[pos[1]][pos[0]]
  3880. self.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['effect'][7])
  3881. self.tilemap[pos[1]][pos[0]].replace = replace
  3882. self.npcs[y][x].move_done = 1
  3883. self.npcs[y][x].num_special -= 1
  3884. if self.npcs[y][x].move_done == 0 and los == True:
  3885. try:
  3886. player.monster_attacks(x,y)
  3887. except:
  3888. None
  3889. self.npcs[y][x].move_done = 1#set the move_done switch on
  3890. elif AI_style == 'flee':
  3891. if distances[0] > 4: #moves[0] is always the position of the monster right now, so distances 0 is always it's distance towards the player
  3892. if len(moves) > 1:
  3893. ran = random.randint(0,len(moves)-1)
  3894. else:
  3895. ran = 0
  3896. do_move = moves[ran]
  3897. else:
  3898. if len(moves) > 0:#if no move is possible at least the 'move' of stay still must remain
  3899. good_moves = []
  3900. for k in range (0, len(moves)):
  3901. if distances[k] > distances[0] or distances[k] == distances[0]:#if the possible move makes the distance between player and monster bigger or at least the same
  3902. good_moves.append(moves[k])
  3903. else:
  3904. good_moves = moves
  3905. if len(good_moves) == 0:
  3906. good_moves = moves
  3907. if len(good_moves) > 1:
  3908. ran = random.randint(0,len(good_moves)-1)
  3909. else:
  3910. ran = 0
  3911. do_move = good_moves[ran]
  3912. elif AI_style == 'ignore':
  3913. ability_keys = self.npcs[y][x].ability.keys()
  3914. if self.npcs[y][x].move_done == 0:
  3915. if 'produce_egg' in ability_keys:
  3916. ran = random.randint(0,999)
  3917. if ran < self.npcs[y][x].ability['produce_egg'] and self.tilemap[y][x].replace == None:
  3918. replace = self.tilemap[y][x]
  3919. self.tilemap[y][x] = deepcopy(tl.tlist['functional'][33])
  3920. self.tilemap[y][x].replace = replace
  3921. if self.npcs[y][x].move_done == 0:
  3922. if len(moves) > 1:
  3923. ran = random.randint(0,len(moves)-1)
  3924. else:
  3925. ran = 0
  3926. do_move = moves[ran]
  3927. elif self.npcs[y][x].AI_style == 'company':
  3928. ability_keys = self.npcs[y][x].ability.keys()
  3929. if self.npcs[y][x].move_done == 0:
  3930. if 'attack_monster' in ability_keys:
  3931. monsters_list = []
  3932. for yy in range (y-1,y+2):
  3933. if self.npcs[yy][x] != 0 and self.npcs[yy][x].AI_style == 'hostile':
  3934. monsters_list.append([x,yy])
  3935. for xx in range(x-1,x+2):
  3936. if self.npcs[y][xx] != 0 and self.npcs[y][xx].AI_style == 'hostile':
  3937. monsters_list.append([xx,y])
  3938. if len(monsters_list) > 0:
  3939. if len(monsters_list) == 1:
  3940. ran = 0
  3941. else:
  3942. ran = random.randint(0,len(monsters_list)-1)
  3943. xxx = monsters_list[ran][0]
  3944. yyy = monsters_list[ran][1]
  3945. rand = random.randint(0,99)
  3946. if 'eat_monster' in ability_keys:
  3947. if rand < self.npcs[y][x].ability['eat_monster']:
  3948. mes = self.npcs[y][x].name + ' [eats] ' + self.npcs[yyy][xxx].name
  3949. message.add(mes)
  3950. sfx.play('eat')
  3951. self.npcs[yyy][xxx] = 0
  3952. self.npcs[y][x].move_done = 1
  3953. if rand < self.npcs[y][x].ability['attack_monster'] and self.npcs[y][x].move_done == 0:
  3954. mes = self.npcs[y][x].name + ' [hits] ' + self.npcs[yyy][xxx].name
  3955. message.add(mes)
  3956. self.npcs[yyy][xxx].lp -= 1
  3957. screen.write_hit_matrix(xxx,yyy,4)
  3958. sfx.play('hit')
  3959. if '-skill' in ability_keys and not '-skill' in self.npcs[yyy][xxx].properties:
  3960. self.npcs[yyy][xxx].properties.append('-skill')
  3961. if self.npcs[yyy][xxx].lp < 1:
  3962. self.monster_die(xxx,yyy)
  3963. self.npcs[y][x].move_done = 0
  3964. if self.npcs[y][x].move_done == 0:
  3965. if 'light' in ability_keys:
  3966. time_night = False
  3967. if time.hour < 6 or time.hour > 19:
  3968. time_night = True
  3969. if time_night == True or player.pos[2] > 0:
  3970. player.buffs.set_buff('light',1,False)
  3971. if self.npcs[y][x].move_done == 0:
  3972. if 'blind' in ability_keys:
  3973. monsters_list = []
  3974. for yy in range (y-1,y+2):
  3975. if self.npcs[yy][x] != 0 and self.npcs[yy][x].AI_style == 'hostile' and not 'blind' in self.npcs[yy][x].properties:
  3976. monsters_list.append([x,yy])
  3977. for xx in range(x-1,x+2):
  3978. if self.npcs[y][xx] != 0 and self.npcs[y][xx].AI_style == 'hostile' and not 'blind' in self.npcs[y][xx].properties:
  3979. monsters_list.append([xx,y])
  3980. if len(monsters_list) > 0:
  3981. if len(monsters_list) == 1:
  3982. ran = 0
  3983. else:
  3984. ran = random.randint(0,len(monsters_list)-1)
  3985. xxx = monsters_list[ran][0]
  3986. yyy = monsters_list[ran][1]
  3987. rand = random.randint(0,99)
  3988. if rand < self.npcs[y][x].ability['blind']:
  3989. mes = self.npcs[y][x].name + ' [blinds] ' + self.npcs[yyy][xxx].name
  3990. message.add(mes)
  3991. self.npcs[yyy][xxx].properties.append('blind')
  3992. self.npcs[y][x].move_done = 1
  3993. #IV. Move the monster
  3994. if do_move != 'foo':
  3995. border = random.randint(1,9)
  3996. if border > self.npcs[y][x].move_border:
  3997. self.npcs[y][x].move_done = 1#set the move_done switch on
  3998. helper = self.npcs[y][x]#copy the monster
  3999. self.npcs[y][x] = 0 #del the monster at the old position
  4000. self.npcs[do_move[1]][do_move[0]] = helper# set monster to the new position
  4001. def monster_die(self,x,y,xp = None):
  4002. #this function is called when the player kills a monster. the x and the y variables are to define the location of the monster
  4003. monster_x = x
  4004. monster_y = y
  4005. real_death = True
  4006. real_drop = False
  4007. if self.tilemap[y][x].replace == None:
  4008. test_replace = True
  4009. else:
  4010. test_replace = False
  4011. if self.npcs[monster_y][monster_x].corps_style == 'make_blobs':
  4012. test_replace = True
  4013. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' vanishes!'
  4014. if test_replace != True or self.tilemap[y][x].drops_here != True:
  4015. location_list = []
  4016. for yy in range(y-1,y+2):
  4017. for xx in range(x-1,x+2):
  4018. if self.tilemap[yy][xx].replace == None and self.npcs[yy][xx] == 0:
  4019. test_replace = True
  4020. else:
  4021. test_replace = False
  4022. if test_replace == True and self.tilemap[yy][xx].drops_here and (self.tilemap[yy][xx].move_group == 'soil' or self.tilemap[yy][xx].move_group == 'dry_entrance') and self.containers[yy][xx] == 0:
  4023. location_list.append((xx,yy))
  4024. if len(location_list) < 1:
  4025. real_death = False
  4026. x = monster_x
  4027. y = monster_y
  4028. elif len(location_list) == 1:
  4029. x = location_list[0][0]
  4030. y = location_list[0][1]
  4031. else:
  4032. ran = random.randint(0,len(location_list)-1)
  4033. x = location_list[ran][0]
  4034. y = location_list[ran][1]
  4035. if test_replace == True and self.tilemap[y][x].drops_here and real_death == True: #only on empty fields corps can be spawned
  4036. if self.npcs[monster_y][monster_x].corps_style == 'dryade' and self.tilemap[y][x].techID != tl.tlist['misc'][0].techID and self.tilemap[y][x].can_grown: #dryades can leave behind a seppling when they are killed(corpse_lvl dosn't matter)/low water isn't allowed
  4037. coin = random.randint(0,99)
  4038. if coin < 50:#there is a chance of 50%
  4039. replace = self.tilemap[y][x]
  4040. self.tilemap[y][x] = tl.tlist['local'][10]#<---sepling
  4041. self.tilemap[y][x].replace = replace
  4042. self.make_monsters_angry(x,y,'tree')
  4043. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' turns into a new tree!'
  4044. elif self.npcs[monster_y][monster_x].corps_style == 'troll' and self.tilemap[y][x].techID != tl.tlist['misc'][0]: #trolls can leave behind a rock when they are killed(corpse_lvl dosn't matter)/low water isn't allowed
  4045. coin = random.randint(0,99)
  4046. if coin < 50:#there is a chance of 50%
  4047. replace = self.tilemap[y][x]
  4048. self.tilemap[y][x] = deepcopy(tl.tlist['local'][14])#<---rock
  4049. self.tilemap[y][x].replace = replace
  4050. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' turns to stone!'
  4051. elif self.npcs[monster_y][monster_x].corps_style == 'human': #humanoid monsters can leave behind humanoid remains when they die. the corps_lvl says how much items are stored inside them
  4052. coin = random.randint(0,99)
  4053. if coin < 15:#there is a chance of 15%
  4054. real_drop = True
  4055. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' dies!'
  4056. replace = self.tilemap[y][x]
  4057. self.tilemap[y][x] = deepcopy(tl.tlist['functional'][6])#<--humanoid remains
  4058. self.tilemap[y][x].replace = replace
  4059. items = []
  4060. max_items = max(1,self.npcs[monster_y][monster_x].corps_lvl)
  4061. for i in range (0, max_items):
  4062. #possible drops of a humanoid monster are equipment items and food items
  4063. coin = random.randint(0,99)
  4064. if coin < 65: #there is a chance of 65% that a item becomes a eqipment item
  4065. material = random.randint(0,20) #all materials are allowed
  4066. classes = ('spear','sword','axe','hammer','shoes','cuisse','helmet','armor','wand','rune','rune staff','artefact','ring','amulet','necklace','talisman','pickaxe')
  4067. kind = classes[random.randint(0,len(classes)-1)]#all classes of objects are allowed
  4068. plus = random.randint(-2,+2)# a plus between -2 and +2 is possible
  4069. state = random.randint(10,85)#the state of this used objects will always be between 10% and 80%
  4070. curse_chance = random.randint(0,30)
  4071. if curse_chance < material:
  4072. curse = 0
  4073. elif curse_chance == material:
  4074. curse = 2
  4075. else:
  4076. curse = 1
  4077. item = item_wear(kind,material,plus,state,curse)
  4078. elif coin < 68: #there is a chance of 3% to drop a simple blueprint
  4079. blueprint = random.randint(15,20)
  4080. item = deepcopy(il.ilist['misc'][blueprint])
  4081. elif coin < 80: #there is a chance of 12% to drop a torch or a throwable:
  4082. item_list = (il.ilist['misc'][44],il.ilist['misc'][44],il.ilist['misc'][44],il.ilist['misc'][78],il.ilist['misc'][79],il.ilist['misc'][80])
  4083. ran = random.randint(0,len(item_list)-1)
  4084. item = deepcopy(item_list[ran])
  4085. else:
  4086. coin2 = random.randint(0,1)
  4087. if coin == 1:
  4088. item = deepcopy(il.ilist['food'][random.randint(0,len(il.ilist['food'])-1)])
  4089. else:
  4090. item_list = (il.ilist['misc'][74],il.ilist['misc'][75],il.ilist['misc'][76],il.ilist['misc'][77])
  4091. ran = random.randint(0,len(item_list)-1)
  4092. item = deepcopy(item_list[ran])
  4093. items.append(item)
  4094. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  4095. elif self.npcs[monster_y][monster_x].corps_style == 'animal': #humanoid monsters can leave behind humanoid remains when they die. the corps_lvl says how much items are stored inside them
  4096. coin = random.randint(0,99)
  4097. if coin < 15:#there is a chance of 15%
  4098. real_drop = True
  4099. replace = self.tilemap[y][x]
  4100. self.tilemap[y][x] = deepcopy(tl.tlist['functional'][21])#<--animal remains
  4101. self.tilemap[y][x].replace = replace
  4102. items = []
  4103. max_items = max(1,self.npcs[monster_y][monster_x].corps_lvl)
  4104. for i in range (0, max_items):
  4105. #animals drop flesh. the corpslvl says how much
  4106. items.append(deepcopy(il.ilist['food'][9]))#<---raw meat
  4107. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  4108. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' dies!'
  4109. elif self.npcs[monster_y][monster_x].corps_style == 'scrollkeeper': #scrollkeepers can leave behind humanoid remains with scrolls and spellbooks when they die. the corps_lvl says how much items are stored inside them
  4110. coin = random.randint(0,99)
  4111. if coin < 10:#there is a chance of 10%
  4112. real_drop = True
  4113. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' dies!'
  4114. replace = self.tilemap[y][x]
  4115. self.tilemap[y][x] = deepcopy(tl.tlist['functional'][6])#<--humanoid remains
  4116. self.tilemap[y][x].replace = replace
  4117. items = []
  4118. max_items = max(1,self.npcs[monster_y][monster_x].corps_lvl)
  4119. for i in range (0, max_items):
  4120. #possible drops of a scrollkeeper are scrolls and spellbooks
  4121. coin = random.randint(0,99)
  4122. if coin < 75: #there is a chance of 75% that a item becomes a scroll
  4123. scrolls = (il.ilist['misc'][25],il.ilist['misc'][27],il.ilist['misc'][29],il.ilist['misc'][31],il.ilist['misc'][33],il.ilist['misc'][35],il.ilist['misc'][37],il.ilist['misc'][45],il.ilist['misc'][82])
  4124. ran = random.randint(0,len(scrolls)-1)
  4125. item = deepcopy(scrolls[ran])
  4126. else:
  4127. books = (il.ilist['misc'][26],il.ilist['misc'][30],il.ilist['misc'][32],il.ilist['misc'][34],il.ilist['misc'][36],il.ilist['misc'][38],il.ilist['misc'][46],il.ilist['misc'][83])
  4128. ran = random.randint(0,len(books)-1)
  4129. item = deepcopy(books[ran])
  4130. items.append(item)
  4131. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  4132. elif self.npcs[monster_y][monster_x].corps_style == 'miner':
  4133. if self.npcs[monster_y][monster_x].techID == ml.mlist['special'][0].techID:#this is a vase
  4134. die_mess = 'The vase shatters.'
  4135. ran = random.randint(0,99)
  4136. if ran <= self.npcs[monster_y][monster_x].corps_lvl: #for miners the corps_lvl determinates the chance of getting a gem
  4137. real_drop = True
  4138. replace = self.tilemap[y][x]
  4139. self.tilemap[y][x] = deepcopy(tl.tlist['misc'][9])#set a lost gem
  4140. self.tilemap[y][x].replace = replace
  4141. elif ran <= self.npcs[monster_y][monster_x].corps_lvl*4:#for miners the corps_lvl determinates the chance of getting some ore. Its the chance to get a gem * 3
  4142. real_drop = True
  4143. replace = self.tilemap[y][x]
  4144. self.tilemap[y][x] = deepcopy(tl.tlist['misc'][11])#set a lost ore
  4145. self.tilemap[y][x].replace = replace
  4146. elif self.npcs[monster_y][monster_x].corps_style == 'thief':
  4147. if self.tilemap[y][x].replace == None and self.npcs[monster_y][monster_x].corps_lvl > 0:
  4148. real_drop = True
  4149. replace = self.tilemap[y][x]
  4150. self.tilemap[y][x] = deepcopy(tl.tlist['misc'][9])#set a lost gem
  4151. self.tilemap[y][x].replace = replace
  4152. self.tilemap[y][x].conected_resources = ('gem',self.npcs[monster_y][monster_x].corps_lvl)#for thiefs the corps lvl determinates the number of gems they are dropping
  4153. elif self.npcs[monster_y][monster_x].corps_style == 'reset_parent':
  4154. parent_id = self.npcs[monster_y][monster_x].personal_id.replace('_child','')
  4155. for yy in range(0,max_map_size):
  4156. for xx in range(0,max_map_size):
  4157. if self.npcs[yy][xx] != 0:
  4158. if self.npcs[yy][xx].personal_id == parent_id:
  4159. self.npcs[yy][xx].num_special += 1
  4160. elif self.npcs[monster_y][monster_x].corps_style == 'kill_childs':
  4161. child_id = self.npcs[monster_y][monster_x].personal_id + '_child'
  4162. for yy in range(0,max_map_size):
  4163. for xx in range(0,max_map_size):
  4164. if self.npcs[yy][xx] != 0:
  4165. if self.npcs[yy][xx].personal_id == child_id:
  4166. self.npcs[yy][xx] = 0
  4167. elif self.npcs[monster_y][monster_x].corps_style == 'kobold_fear':
  4168. for yy in range(y-7,y+8):
  4169. for xx in range(x-7,x+8):
  4170. try:
  4171. if self.npcs[yy][xx].techID == ml.mlist['kobold'][1].techID and self.npcs[yy][xx].name != 'frightened kobold':
  4172. self.npcs[yy][xx] = deepcopy(self.npcs[yy][xx])#only to be sure
  4173. self.npcs[yy][xx].name = 'frightened kobold'
  4174. self.npcs[yy][xx].sprite_pos = (5,3)
  4175. self.npcs[yy][xx].basic_attribute.p_strength = int(self.npcs[yy][xx].basic_attribute.p_strength*0.6)
  4176. self.npcs[yy][xx].basic_attribute.m_strength = int(self.npcs[yy][xx].basic_attribute.m_strength*0.6)
  4177. self.npcs[yy][xx].basic_attribute.p_defense = int(self.npcs[yy][xx].basic_attribute.p_defense*0.6)
  4178. self.npcs[yy][xx].basic_attribute.m_defense = int(self.npcs[yy][xx].basic_attribute.m_defense*0.6)
  4179. screen.write_hit_matrix(xx,yy,17)
  4180. coin = random.randint(0,1)
  4181. if coin == 1:
  4182. self.npcs[yy][xx].AI_style = 'flee'
  4183. except:
  4184. None
  4185. elif self.npcs[monster_y][monster_x].corps_style == 'vase':
  4186. die_mess = 'The vase shatters and monsters jump out.'
  4187. monster_count = 0
  4188. for yy in range(y-1,y+2):
  4189. for xx in range(x-1,x+2):
  4190. if yy != player.pos[1] or xx!= player.pos[0]:
  4191. if self.npcs[yy][xx] == 0 and self.tilemap[yy][xx].move_group == 'soil' and self.tilemap[yy][xx].damage == 0:
  4192. self.npcs[yy][xx] = deepcopy(ml.mlist['special'][2])#set vase monsters
  4193. self.set_monster_strength(xx,yy,player.pos[2])
  4194. if player.difficulty == 4:
  4195. self.npcs[yy][xx].AI_style = 'ignore'
  4196. monster_count += 1
  4197. if monster_count > 0:
  4198. die_mess = 'The vase shatters and '+str(monster_count)+' monsters jump out.'
  4199. else:
  4200. die_mess = 'The vase shatters.'
  4201. elif self.npcs[monster_y][monster_x].corps_style == 'mimic':
  4202. die_mess = 'The mimic wakes up.'
  4203. elif self.npcs[monster_y][monster_x].corps_style == 'cage':
  4204. die_mess = 'You smash the cage!'
  4205. sfx.play('destroy_cage')
  4206. elif self.npcs[monster_y][monster_x].corps_style == 'make_blobs':
  4207. counter = 0
  4208. blob_lvl = max(self.npcs[monster_y][monster_x].lvl-1,0)
  4209. for yy in range(y-1,y+2):
  4210. for xx in range(x-1,x+2):
  4211. if yy != y or xx != x:
  4212. not_player_pos = yy != player.pos[1] or xx != player.pos[0]
  4213. if self.tilemap[yy][xx].move_group == 'soil' and not_player_pos == True and self.npcs[yy][xx] == 0:
  4214. self.npcs[yy][xx] = deepcopy(ml.mlist['special'][15])#set a green blob
  4215. self.set_monster_strength(xx,yy,player.pos[2],preset_lvl=blob_lvl)
  4216. if player.difficulty == 4:
  4217. self.npcs[yy][xx].AI_style = 'ignore'
  4218. counter += 1
  4219. if counter == 1:
  4220. die_mess = 'The giant blob leaves behind a small blob.'
  4221. elif counter > 1:
  4222. die_mess = 'The giant blob bursts into '+str(counter)+' small blobs.'
  4223. elif self.npcs[monster_y][monster_x].corps_style == 'life_essence':
  4224. real_drop = True
  4225. replace = self.tilemap[y][x]
  4226. self.tilemap[y][x] = deepcopy(tl.tlist['functional'][35])#set a life essence
  4227. self.tilemap[y][x].replace = replace
  4228. elif self.npcs[monster_y][monster_x].corps_style == 'vanish':
  4229. ran = random.randint(0,99)
  4230. if ran <= self.npcs[monster_y][monster_x].corps_lvl: #the corps_lvl determinates the chance of getting a present
  4231. real_drop = True
  4232. replace = self.tilemap[y][x]
  4233. self.tilemap[y][x] = deepcopy(tl.tlist['misc'][13])#set a present
  4234. self.tilemap[y][x].replace = replace
  4235. item_ran = random.randint(0,99)
  4236. if item_ran < 25:
  4237. items = [il.ilist['misc'][43]]#set a heavy bag
  4238. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  4239. elif item_ran < 50:
  4240. choose_ran = random.randint(0,len(il.ilist['clothe'])-1)
  4241. items = [il.ilist['clothe'][choose_ran]]
  4242. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  4243. elif item_ran < 95:
  4244. r = random.randint(3,7)
  4245. items = [il.ilist['misc'][r]]#set a workbench
  4246. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  4247. else:
  4248. items = [il.ilist['misc'][70]]#set a book of skill
  4249. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  4250. ############ADD MORE HERE###############
  4251. if real_drop == True:
  4252. screen.write_hit_matrix(x,y,16)
  4253. if self.npcs[monster_y][monster_x].move_border < 10:
  4254. screen.write_hit_matrix(monster_x,monster_y,13)
  4255. if self.npcs[monster_y][monster_x].corps_style == 'mimic':
  4256. self.npcs[monster_y][monster_x] = deepcopy(ml.mlist['special'][4])#set a mimic
  4257. self.set_monster_strength(monster_x,monster_y,player.pos[2])
  4258. if player.difficulty == 4:
  4259. self.npcs[monster_y][monster_x].AI_style = 'ignore'
  4260. elif self.npcs[monster_y][monster_x].corps_style == 'cage':
  4261. self.npcs[monster_y][monster_x] = deepcopy(ml.mlist['rescued'][0])
  4262. self.set_monster_strength(monster_x,monster_y,player.pos[2])
  4263. else:
  4264. self.npcs[monster_y][monster_x] = 0 #always del the monster if it is no mimic or cage
  4265. self.make_monsters_angry(monster_x,monster_y,'kill')
  4266. self.monster_count -= 1
  4267. if xp != None:
  4268. die_mess = die_mess + ' [+' + str(xp) + 'xp]'
  4269. message.add(die_mess)
  4270. return True
  4271. def make_shops(self):
  4272. num = int((max_map_size*max_map_size) / (50*50))
  4273. for i in range (0,num):
  4274. run = True
  4275. while run:
  4276. poses = self.find_all_moveable(False,False)
  4277. ran = random.randint(0,len(poses)-1)
  4278. pos = poses[ran]
  4279. if min(pos[0],pos[1]) > 4 and max(pos[0],pos[1]) < max_map_size-4:
  4280. run = False
  4281. x = pos[0]
  4282. y = pos[1]
  4283. for yy in range(y-2,y+3):
  4284. for xx in range(x-2,x+3):
  4285. self.npcs[yy][xx] = 0 #always del the monsters
  4286. if xx == x-2 or xx == x+2 or yy == y-2 or yy == y+2:
  4287. self.tilemap[yy][xx] = deepcopy(tl.tlist['shop'][1])
  4288. else:
  4289. self.tilemap[yy][xx] = deepcopy(tl.tlist['shop'][0])
  4290. self.tilemap[y][x-2] = deepcopy(tl.tlist['shop'][2])
  4291. self.tilemap[y][x+2] = deepcopy(tl.tlist['shop'][2])
  4292. self.tilemap[y-2][x] = deepcopy(tl.tlist['shop'][2])
  4293. self.tilemap[y+2][x] = deepcopy(tl.tlist['shop'][2])
  4294. if self.map_type == 'orcish_mines':
  4295. self.npcs[y][x] = deepcopy(ml.mlist['shop'][1])
  4296. elif self.map_type == 'grot':
  4297. self.npcs[y][x] = deepcopy(ml.mlist['shop'][2])
  4298. else:
  4299. self.npcs[y][x] = deepcopy(ml.mlist['shop'][0])#the elfish shopkeeper is only for fallback...In the elfish fortress the shops are spawned on a other way
  4300. def make_monsters_angry(self,x,y,style):
  4301. for yy in range(y-3,y+4):
  4302. for xx in range(x-3,x+4):
  4303. try:
  4304. if self.npcs[yy][xx] != 0:
  4305. if self.npcs[yy][xx].anger == style:
  4306. lvl = self.npcs[yy][xx].lvl
  4307. self.npcs[yy][xx] = deepcopy(ml.mlist['angry_monster'][self.npcs[yy][xx].anger_monster])
  4308. self.set_monster_strength(xx,yy,player.pos[2],lvl)
  4309. if player.difficulty == 4:
  4310. self.npcs[yy][xx].AI_style = 'ignore'
  4311. except:
  4312. None
  4313. def time_pass(self):
  4314. #This function refresches the map for every day that past since players last visit... make plants growing etc.
  4315. if self.last_visit != time.day_total:
  4316. screen.render_load(10)
  4317. past_time = time.day_total - self.last_visit
  4318. if past_time < 0:
  4319. past_time = 364 - past_time
  4320. for c in range (0,past_time):
  4321. for y in range (0,max_map_size):
  4322. for x in range(0,max_map_size):
  4323. tile = self.tilemap[y][x]
  4324. #######Life of plants######
  4325. #1. Scrub
  4326. if tile.grow_group == 'scrub':
  4327. rand = random.randint(0,99)
  4328. if rand < 50:
  4329. replace = self.tilemap[y][x].replace
  4330. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  4331. self.tilemap[y][x].replace = replace
  4332. if tile.grow_group == 'scrub_buds':
  4333. rand = random.randint(0,99)
  4334. if rand < 90:
  4335. replace = self.tilemap[y][x].replace
  4336. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  4337. self.tilemap[y][x].replace = replace
  4338. if tile.grow_group == 'scrub_blossom':
  4339. rand = random.randint(0,99)
  4340. if rand < 80:
  4341. scrubs = random.randint(0,2)
  4342. replace = self.tilemap[y][x].replace
  4343. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[scrubs][0]][tile.conected_tiles[scrubs][1]])
  4344. self.tilemap[y][x].replace = replace
  4345. if tile.grow_group == 'scrub_berries':
  4346. rand = random.randint(0,99)
  4347. if rand < 50:
  4348. replace = self.tilemap[y][x].replace
  4349. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0][0]][tile.conected_tiles[0][1]])
  4350. self.tilemap[y][x].replace = replace
  4351. elif rand > 49 and rand < 75:
  4352. numbers =(-1,1)
  4353. for yy in numbers:
  4354. for xx in numbers:
  4355. try:
  4356. if self.tilemap[y+yy][x+xx].can_grown == True:
  4357. coin = random.randint(0,99)
  4358. if coin < 25: #25%
  4359. replace = self.tilemap[y+yy][x+xx]
  4360. self.tilemap[y+yy][x+xx] = deepcopy([tile.conected_tiles[1][0]][tile.conected_tiles[1][1]])
  4361. self.tilemap[y+yy][x+xx].replace = replace
  4362. except:
  4363. None
  4364. if tile.grow_group == 'scrub_scruffy':
  4365. rand = random.randint(0,99)
  4366. if rand < 90:
  4367. replace = self.tilemap[y][x].replace
  4368. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0][0]][tile.conected_tiles[0][1]])
  4369. self.tilemap[y][x].replace = replace
  4370. else:
  4371. replace = self.tilemap[y][x].replace
  4372. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[1][0]][tile.conected_tiles[1][1]])
  4373. self.tilemap[y][x].replace = replace
  4374. if tile.grow_group == 'scrub_grow':
  4375. rand = random.randint(0,99)
  4376. if rand < 90:
  4377. replace = self.tilemap[y][x].replace
  4378. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  4379. self.tilemap[y][x].replace = replace
  4380. #2.Tree
  4381. if tile.grow_group == 'tree_grow':
  4382. rand = random.randint(0,99)
  4383. if rand < 80 and self.npcs[y][x] == 0:
  4384. replace = self.tilemap[y][x].replace
  4385. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  4386. self.tilemap[y][x].replace = replace
  4387. if tile.grow_group == 'tree':
  4388. rand = random.randint(0,99)
  4389. if rand < 5:
  4390. replace = self.tilemap[y][x].replace
  4391. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[1][0]][tile.conected_tiles[1][1]])
  4392. self.tilemap[y][x].replace = replace
  4393. elif rand > 69:
  4394. numbers =(-2,2)
  4395. for yy in numbers:
  4396. for xx in numbers:
  4397. try:
  4398. if self.tilemap[y+yy][x+xx].can_grown == True:
  4399. coin = random.randint(0,3)
  4400. if coin == 0:
  4401. replace = self.tilemap[y+yy][x+xx]
  4402. self.tilemap[y+yy][x+xx] = deepcopy(tl.tlist[tile.conected_tiles[0][0]][tile.conected_tiles[0][1]])
  4403. self.tilemap[y+yy][x+xx].replace = replace
  4404. except:
  4405. None
  4406. #3.Herb
  4407. if tile.grow_group == 'herblike':
  4408. rand = random.randint(0,99)
  4409. if rand < 20:
  4410. replace = self.tilemap[y][x].replace
  4411. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  4412. self.tilemap[y][x].replace = replace
  4413. #4. Blue Mushrooms
  4414. if tile.grow_group == 'mushroom_mud':
  4415. rand = random.randint(0,99)
  4416. if rand < 5:
  4417. for yy in range(-1,1):
  4418. for xx in range(-1,1):
  4419. try:
  4420. if self.tilemap[y+yy][x+xx].techID == tl.tlist['misc'][1].techID:#here is mud
  4421. cent = random.randint(0,99)
  4422. if cent < 25 :
  4423. replace = self.tilemap[y+yy][x+xx]
  4424. self.tilemap[y+yy][x+xx] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  4425. self.tilemap[y+yy][x+xx].replace = replace
  4426. except:
  4427. None
  4428. #5. Brown Mushrooms
  4429. if tile.grow_group == 'mushroom_treelike':
  4430. rand = random.randint(0,99)
  4431. if rand < 5:
  4432. for yy in range(-1,1):
  4433. for xx in range(-1,1):
  4434. try:
  4435. if self.tilemap[y+yy][x+xx].techID == tl.tlist['global_caves'][0].techID:#here is cave ground
  4436. cent = random.randint(0,99)
  4437. if cent < 25 :
  4438. replace = self.tilemap[y+yy][x+xx]
  4439. self.tilemap[y+yy][x+xx] = deepcopy(tl.tlist[tile.conected_tiles[0][0]][tile.conected_tiles[0][1]])
  4440. self.tilemap[y+yy][x+xx].replace = replace
  4441. except:
  4442. None
  4443. elif rand < 30:#make a giant mushroom
  4444. replace = self.tilemap[y][x].replace
  4445. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[1][0]][tile.conected_tiles[1][1]])
  4446. self.tilemap[y][x].replace = replace
  4447. #6. Purple Mushrooms
  4448. if tile.grow_group == 'mushroom': #let grow new mushrooms and let the old ones die(5%)
  4449. rand = random.randint(0,99)
  4450. if rand < 5:
  4451. for yy in range(-1,1):
  4452. for xx in range(-1,1):
  4453. try:
  4454. if self.tilemap[y+yy][x+xx].techID == tl.tlist['global_caves'][0].techID:#here is cave ground
  4455. cent = random.randint(0,99)
  4456. if cent < 25 :
  4457. replace = self.tilemap[y+yy][x+xx]
  4458. self.tilemap[y+yy][x+xx] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  4459. self.tilemap[y+yy][x+xx].replace = replace
  4460. except:
  4461. None
  4462. #7. Agriculture
  4463. if tile.grow_group == 'agri0':
  4464. rand = random.randint(0,99)
  4465. if rand < 50:
  4466. if self.map_type == 'overworld':
  4467. self.tilemap[y][x] = tl.tlist[tile.conected_tiles[0][0]][tile.conected_tiles[0][1]]
  4468. elif self.map_type == 'cave' or self.map_type == 'desert_cave':
  4469. self.tilemap[y][x] = tl.tlist[tile.conected_tiles[1][0]][tile.conected_tiles[1][1]]
  4470. elif self.map_type == 'desert':
  4471. self.tilemap[y][x] = tl.tlist[tile.conected_tiles[2][0]][tile.conected_tiles[2][1]]
  4472. if tile.grow_group == 'agri1': #let something grow on a acriculture (final, at the overworld) (50%)
  4473. rand = random.randint(0,99)
  4474. if rand < 50:
  4475. self.tilemap[y][x] = tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]]
  4476. #8. Vanish
  4477. if tile.grow_group == 'vanish':
  4478. rand = random.randint(0,99)
  4479. if rand < 50:
  4480. self.tilemap[y][x] = self.tilemap[y][x].replace
  4481. self.containers[y][x] = 0
  4482. #9. Magic shops
  4483. if tile.techID == tl.tlist['shop'][4].techID and player.on_map != 'shop_0_0':
  4484. self.tilemap[y][x] = self.tilemap[y][x].replace
  4485. #######Misc#######
  4486. #0. Rubble
  4487. if tile.techID == tl.tlist['functional'][26].techID:
  4488. rand = random.randint(0,99)
  4489. if rand < 20:
  4490. count_rubble = 0
  4491. count_sand = 0
  4492. count_grass = 0
  4493. count_cave = 0
  4494. for yy in range(y-1,y+2):
  4495. for xx in range(x-1,x+2):
  4496. if self.tilemap[yy][xx].techID == tl.tlist['functional'][26]:#this is rubble
  4497. count_rubble += 1
  4498. elif self.tilemap[yy][xx].techID == tl.tlist['local'][0]:#this is grass
  4499. count_grass += 1
  4500. elif self.tilemap[yy][xx].techID == tl.tlist['extra'][0]:#this is sand
  4501. count_sand += 1
  4502. elif self.tilemap[yy][xx].techID == tl.tlist['global_caves'][0]:#this is cave
  4503. count_cave +=1
  4504. if count_rubble < 8: #this tile isnt surrounded by rubble
  4505. if count_cave > 1:
  4506. self.tilemap[y][x] = deepcopy(tl.tlist['global_caves'][0])
  4507. elif count_grass >= count_sand:
  4508. self.tilemap[y][x] = deepcopy(tl.tlist['local'][0])
  4509. else:
  4510. self.tilemap[y][x] = deepcopy(tl.tlist['extra'][0])
  4511. #1. nest box (with egg)
  4512. if tile.grow_group == 'hatch':
  4513. rand = random.randint(0,99)
  4514. if rand < 80 and self.npcs[y][x] == 0:
  4515. replace = self.tilemap[y][x].replace
  4516. self.tilemap[y][x] = deepcopy(tl.tlist['sanctuary'][4])
  4517. self.tilemap[y][x].replace = replace
  4518. pet_num = []
  4519. for i in range(0,len(ml.mlist['pet']),3):
  4520. pet_num.append(i)
  4521. ran = random.randint(0,len(pet_num)-1)
  4522. num = pet_num[ran]
  4523. self.npcs[y][x] = deepcopy(ml.mlist['pet'][num])
  4524. self.set_monster_strength(x,y,1)
  4525. #########add other events for growing plants etc here########
  4526. self.last_visit = time.day_total #change the day of last visit to today to prevent the map of changed a second time for this day
  4527. if player.on_map != 'shop_0_0':
  4528. shop_num = int((max_map_size**2)/(50**2))
  4529. self.spawn_magic_shops(shop_num)
  4530. screen.render_load(5)
  4531. save(world,player,time,gods,save_path,os.sep)
  4532. def exchange(self,old_tile,new_tile,use_deepcopy=False):
  4533. for y in range (0,max_map_size):
  4534. for x in range (0,max_map_size):
  4535. if self.tilemap[y][x].techID == old_tile.techID:
  4536. if use_deepcopy == False:
  4537. self.tilemap[y][x] = new_tile
  4538. else:
  4539. self.tilemap[y][x] = deepcopy(new_tile)
  4540. def find_first(self,tile):
  4541. for y in range (0,max_map_size):
  4542. for x in range (0,max_map_size):
  4543. if self.tilemap[y][x].techID == tile.techID:
  4544. return [x,y]
  4545. if self.tilemap[y][x].name == tile.name:#fallback
  4546. return [x,y] #
  4547. return False
  4548. def find_any(self,tile):
  4549. found = []
  4550. for y in range(0,max_map_size):
  4551. for x in range(0,max_map_size):
  4552. if self.tilemap[y][x].techID == tile.techID and self.npcs[y][x] == 0:
  4553. found.append((x,y))
  4554. if found == []:
  4555. return False
  4556. elif len(found) == 1:
  4557. return found[0]
  4558. else:
  4559. ran = random.randint(0,len(found)-1)
  4560. return found[ran]
  4561. def find_all_moveable(self,ignore_water = True,ignore_player_pos = False, ignore_no_spawn = True):
  4562. cordinates_list = []
  4563. for y in range (0, max_map_size):
  4564. for x in range (0,max_map_size):
  4565. moveable = False
  4566. if ignore_water == True:
  4567. if self.tilemap[y][x].move_group == 'soil':
  4568. moveable = True
  4569. else:
  4570. if self.tilemap[y][x].move_group == 'soil' or self.tilemap[y][x].move_group == 'low_liquid':
  4571. moveable = True
  4572. if ignore_player_pos == True:
  4573. player_pos_check = False
  4574. else:
  4575. if (x - entrance_x < -7) or (y - entrance_y < -7) or (x - entrance_x > 7) or (y - entrance_y > 7):
  4576. player_pos_check = False
  4577. else:
  4578. player_pos_check = True
  4579. spawn_check = True
  4580. if ignore_no_spawn == False:
  4581. if self.tilemap[y][x].no_spawn == True:
  4582. spawn_check = False
  4583. if (moveable == True) and (self.tilemap[y][x].damage == False) and (player_pos_check == False) and (spawn_check == True) and self.npcs[y][x] == 0:
  4584. cordinates_list.append((x,y))
  4585. if len(cordinates_list) > 0:
  4586. return cordinates_list
  4587. else:
  4588. return False
  4589. def add_container(self, inventory, x, y, deep_copy = True, checkIt = False):
  4590. self.containers[y][x] = container(inventory,deep_copy)
  4591. if checkIt == True:
  4592. if self.check_container(x,y) != True:
  4593. print('Container creation failed!')
  4594. self.containers[y][x] = 0
  4595. self.tilemap[y][x] = self.tilemap[y][x].replace
  4596. def check_container(self,x,y):
  4597. if self.tilemap[y][x].replace != None and len(self.containers[y][x].items) > 0:
  4598. return True
  4599. else:
  4600. return False
  4601. def special_check(self,x,y):
  4602. sfx_flame = False
  4603. sfx_vapor = False
  4604. for yy in range(y-7,y+8):
  4605. for xx in range(x-7,x+8):
  4606. try:
  4607. if (self.tilemap[yy][xx].special_group == 'flamable' or self.tilemap[yy][xx].special_group == 'highly flamable') and self.tilemap[yy][xx].replace != None:
  4608. heat_source = 0
  4609. for yyy in range(yy-1,yy+2):
  4610. for xxx in range(xx-1,xx+2):
  4611. try:
  4612. if self.tilemap[yyy][xxx].special_group == 'hot':
  4613. heat_source += 1
  4614. except:
  4615. None
  4616. if heat_source > 0:
  4617. if self.tilemap[yy][xx].special_group == 'flamable':
  4618. ran = random.randint(0,9)
  4619. else:
  4620. ran = 9
  4621. if ran > 5:
  4622. sfx_flame = True
  4623. self.containers[yy][xx] = 0
  4624. if world.maplist[player.pos[2]][player.on_map].npcs[yy][xx] != 0:
  4625. if world.maplist[player.pos[2]][player.on_map].npcs[yy][xx].techID == ml.mlist['special'][14].techID: #this is a demonic chest
  4626. world.maplist[player.pos[2]][player.on_map].monster_die(xx,yy)
  4627. self.countdowns.append(countdown('flame',xx,yy,self.tilemap[yy][xx].special_num))
  4628. replace = self.tilemap[yy][xx].replace
  4629. self.tilemap[yy][xx] = deepcopy(tl.tlist['effect'][4])
  4630. self.tilemap[yy][xx].replace = replace
  4631. elif self.tilemap[yy][xx].special_group == 'explosive' or self.tilemap[yy][xx].special_group == 'highly explosive':
  4632. heat_sources = 0
  4633. for yyy in range(yy-1,yy+2):
  4634. for xxx in range(xx-1,xx+2):
  4635. try:
  4636. if self.tilemap[yyy][xxx].special_group == 'hot':
  4637. heat_sources += 1
  4638. except:
  4639. None
  4640. if heat_sources > 0:
  4641. if self.tilemap[yyy][xxx].special_group == 'explosive':
  4642. ran = random.randint(0,9)
  4643. else:
  4644. ran = 9
  4645. if ran > 5:
  4646. self.countdowns.append(countdown('bomb1',xx,yy,1))
  4647. for yyy in range(yy-1,yy+2):
  4648. for xxx in range(xx-1,xx+2):
  4649. try:
  4650. if self.tilemap[yyy][xxx].special_group == 'explosive' or elf.tilemap[yyy][xxx].special_group == 'highly explosive':
  4651. self.countdowns.append(countdown('bomb1',xxx,yyy,1))
  4652. except:
  4653. None
  4654. elif self.tilemap[yy][xx].special_group == 'vaporable':
  4655. heat_sources = 0
  4656. for yyy in range(yy-1,yy+2):
  4657. for xxx in range(xx-1,xx+2):
  4658. try:
  4659. if self.tilemap[yyy][xxx].special_group == 'hot':
  4660. heat_sources += 1
  4661. except:
  4662. None
  4663. if heat_sources >= self.tilemap[yy][xx].special_num:
  4664. sfx.vapor = True
  4665. self.tilemap[yy][xx] = deepcopy(tl.tlist['misc'][1])#mud
  4666. except:
  4667. None
  4668. if sfx_flame == True:
  4669. sfx.play('flame')
  4670. if sfx_vapor == True:
  4671. sfx.play('steam')
  4672. def spawn_monster_groups(self,leader,follower,max_group_size):
  4673. for y in range(0,max_map_size):
  4674. for x in range(0,max_map_size):
  4675. if self.npcs[y][x] != 0 and self.npcs[y][x].techID == leader.techID:
  4676. m_count = 1
  4677. for yy in range(y-1,y+2):
  4678. for xx in range(x-1,x+2):
  4679. if m_count < max_group_size and self.npcs[yy][xx] == 0 and self.tilemap[yy][xx].move_group in follower.move_groups:
  4680. self.npcs[yy][xx] = deepcopy(follower)
  4681. self.set_monster_strength(xx,yy,max(self.npcs[y][x].lvl-5,1))
  4682. if player.difficulty == 4:
  4683. self.npcs[yy][xx].AI_style = 'ignore'
  4684. m_count += 1
  4685. def make_special_monsters(self, min_no, max_no, on_tile, depth, monster_type='vase'):
  4686. size = int((max_map_size*max_map_size)/(50*50))
  4687. for i in range(0,size):
  4688. num_monster = random.randint(min_no,max_no)
  4689. if num_monster > 0:
  4690. for z in range (0,num_monster):
  4691. pos = self.find_any(on_tile)
  4692. if monster_type == 'vase':
  4693. ran = random.randint(0,99)
  4694. if ran < 10:
  4695. self.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['special'][1]) #spawn a monster vase
  4696. self.npcs[pos[1]][pos[0]].attribute = attribute(0,0,0,0,0,1,0)
  4697. else:
  4698. self.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['special'][0]) #spawn a vase
  4699. self.npcs[pos[1]][pos[0]].attribute = attribute(0,0,0,0,0,1,0)
  4700. elif monster_type == 'mimic':
  4701. pos = self.find_any(on_tile)
  4702. self.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['special'][3]) #spawn a sleeping mimic
  4703. self.npcs[pos[1]][pos[0]].attribute = attribute(0,0,0,0,0,1,0)
  4704. elif monster_type == 'animated statue':
  4705. pos = self.find_any(on_tile)
  4706. self.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['special'][17])
  4707. self.set_monster_strength(pos[0],pos[1],depth)
  4708. if player.difficulty == 4:
  4709. self.npcs[pos[1]][pos[0]].AI_style = 'ignore'
  4710. elif monster_type == 'demonic chest':
  4711. pos = self.find_any(on_tile)
  4712. self.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['functional'][4])#cest
  4713. self.tilemap[pos[1]][pos[0]].replace = deepcopy(on_tile)
  4714. sb = (il.ilist['misc'][26],il.ilist['misc'][30],il.ilist['misc'][32],il.ilist['misc'][34],il.ilist['misc'][36],il.ilist['misc'][38],il.ilist['misc'][46],il.ilist['misc'][83])
  4715. ran1 = random.randint(0,len(sb)-1)
  4716. ran2 = random.randint(0,len(sb)-1)
  4717. items = [sb[ran1],sb[ran2]]
  4718. self.containers[pos[1]][pos[0]] = container(items,True)
  4719. self.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['special'][14])
  4720. self.set_monster_strength(pos[0],pos[1],depth)
  4721. if player.difficulty == 4:
  4722. self.npcs[pos[1]][pos[0]].AI_style = 'ignore'
  4723. #set monsters personal_id
  4724. self.npcs[pos[1]][pos[0]].personal_id = str(self.npcs[pos[1]][pos[0]].techID)+'_'+str(pos[0])+'_'+str(pos[1])+'_'+str(random.randint(0,9999))
  4725. def make_containers(self, min_no, max_no, on_tile, item_min, item_max, container_type='remains'):
  4726. size = int((max_map_size*max_map_size)/(50*50))
  4727. for i in range(0,size):
  4728. num_container = random.randint(min_no,max_no)
  4729. if num_container > 0:
  4730. for z in range (0,num_container):
  4731. c_type = container_type
  4732. if c_type == 'chest':
  4733. ch = random.randint(0,99)
  4734. if ch < 5:
  4735. c_type = 'fridge'
  4736. place = self.find_any(on_tile)
  4737. inventory = []
  4738. num_items = random.randint(item_min,item_max)##############item_min,item_max
  4739. for t in range (0,num_items):
  4740. if c_type == 'chest':
  4741. coin = random.randint(0,1)
  4742. if coin == 0:#add equipmen
  4743. classes = ['sword', 'axe', 'hammer', 'spear', 'helmet', 'armor', 'cuisse', 'shoes', 'wand', 'rune', 'rune staff', 'artefact', 'amulet', 'ring', 'talisman', 'necklace', 'pickaxe']
  4744. class_num = random.randint(0,len(classes)-1)
  4745. material = random.randint(0,20)
  4746. plus = random.randint(-3,3)
  4747. state = random.randint(80,100)
  4748. curse_chance = random.randint(0,30)
  4749. if curse_chance < material:
  4750. curse = 0
  4751. elif curse_chance == material:
  4752. curse = 2
  4753. else:
  4754. curse = 1
  4755. item = item_wear(classes[class_num], material, plus, state, curse, False)
  4756. inventory.append(item)
  4757. elif coin == 1:
  4758. items = []
  4759. for i in range(14,21):
  4760. items.append(il.ilist['misc'][i])
  4761. for i in range(22,40):
  4762. items.append(il.ilist['misc'][i])
  4763. for i in range(44,47):
  4764. items.append(il.ilist['misc'][i])
  4765. for j in range(6,9):
  4766. items.append(il.ilist['food'][j])
  4767. for j in range(13,25):
  4768. items.append(il.ilist['food'][j])
  4769. for j in range(29,32):
  4770. items.append(il.ilist['food'][j])
  4771. ran = random.randint(0,len(items)-1)
  4772. inventory.append(deepcopy(items[ran]))
  4773. elif c_type == 'remains':
  4774. classes = ['sword', 'axe', 'hammer', 'spear', 'helmet', 'armor', 'cuisse', 'shoes', 'wand', 'rune', 'rune staff', 'artefact', 'amulet', 'ring', 'talisman', 'necklace', 'pickaxe']
  4775. class_num = random.randint(0,len(classes)-1)
  4776. material = random.randint(0,20)
  4777. plus = random.randint(-3,3)
  4778. state = random.randint(20,60)
  4779. curses = (0,1,2)
  4780. curse_num = random.randint(0,2)
  4781. item = item_wear(classes[class_num], material, plus, state, curses[curse_num], False)
  4782. inventory.append(item)
  4783. elif c_type == 'fridge':
  4784. ran = random.randint(0,len(il.ilist['food'])-1)
  4785. inventory.append(deepcopy(il.ilist['food'][ran]))
  4786. if c_type == 'chest':
  4787. self.add_container(inventory, place[0], place[1])
  4788. replace = self.tilemap[place[1]][place[0]]
  4789. self.tilemap[place[1]][place[0]] = deepcopy(tl.tlist['functional'][4])#chest
  4790. self.tilemap[place[1]][place[0]].replace = replace
  4791. elif c_type == 'remains':
  4792. replace_tile = self.tilemap[place[1]][place[0]]
  4793. self.add_container(inventory, place[0], place[1])
  4794. self.tilemap[place[1]][place[0]] = deepcopy(tl.tlist['functional'][6])#remains
  4795. self.tilemap[place[1]][place[0]].replace = replace_tile
  4796. elif c_type == 'fridge':
  4797. replace_tile = self.tilemap[place[1]][place[0]]
  4798. self.add_container(inventory, place[0], place[1])
  4799. self.tilemap[place[1]][place[0]] = deepcopy(tl.tlist['functional'][25])#fridge
  4800. self.tilemap[place[1]][place[0]].replace = replace_tile
  4801. def exchange_when_surrounded(self, tile_check, tile_replace, number_neighbors):
  4802. #check all cordinates for their neighbors(including them self) and exchange th tile when the number of neighbors with the same techID => number_neighbors
  4803. for y in range (0,max_map_size):
  4804. for x in range (0,max_map_size):
  4805. count = 0
  4806. for yy in range (-1,2):
  4807. for xx in range (-1,2):
  4808. try:
  4809. if self.tilemap[y+yy][x+xx].techID == tile_check.techID or self.tilemap[y+yy][x+xx].techID == tile_replace.techID:
  4810. count += 1
  4811. except:
  4812. None
  4813. if count >= number_neighbors:
  4814. self.tilemap[y][x] = tile_replace
  4815. def sget(self):
  4816. string = ''
  4817. for c in range (0,max_map_size):
  4818. for d in range (0,max_map_size):
  4819. if d != player.pos[0] or c != player.pos[1]:
  4820. if self.known[c][d] != 0:
  4821. string = string + self.tilemap[c][d].char
  4822. else:
  4823. string += '\033[0;30;40m '
  4824. else:
  4825. string = string + player.char
  4826. string = string + '\n'
  4827. return string
  4828. def spawn_magic_shops(self,num=1):
  4829. if self.name == 'shop_0_0':
  4830. return False
  4831. pos = []
  4832. for i in range(0,num):
  4833. for y in range(0,max_map_size):
  4834. for x in range(0,max_map_size):
  4835. if self.tilemap[y][x].move_group == 'solid':
  4836. num_soil = 0
  4837. try:
  4838. if self.tilemap[y-1][x].move_group == 'soil':
  4839. num_soil += 1
  4840. except:
  4841. None
  4842. try:
  4843. if self.tilemap[y+1][x].move_group == 'soil':
  4844. num_soil += 1
  4845. except:
  4846. None
  4847. try:
  4848. if self.tilemap[y][x-1].move_group == 'soil':
  4849. num_soil += 1
  4850. except:
  4851. None
  4852. try:
  4853. if self.tilemap[y][x+1].move_group == 'soil':
  4854. num_soil += 1
  4855. except:
  4856. None
  4857. if num_soil > 0:
  4858. pos.append((x,y))
  4859. if len(pos) < 1:
  4860. return False
  4861. ran = random.randint(0,len(pos)-1)
  4862. replace = deepcopy(self.tilemap[pos[ran][1]][pos[ran][0]])
  4863. self.tilemap[pos[ran][1]][pos[ran][0]] = deepcopy(tl.tlist['shop'][4])
  4864. self.tilemap[pos[ran][1]][pos[ran][0]].replace = replace
  4865. def set_sanctuary(self,startx,starty):
  4866. for y in range (starty-2, starty+3):
  4867. for x in range (startx-2, startx+3):
  4868. self.tilemap[y][x] = deepcopy(tl.tlist['sanctuary'][0])#sanctuary floor
  4869. if x == startx-2 or x == startx or x == startx+2:
  4870. if y == starty-2 or y == starty or y == starty+2:
  4871. self.tilemap[y][x] = deepcopy(tl.tlist['sanctuary'][1])#sanctuary pilar
  4872. self.tilemap[starty][startx] = deepcopy(tl.tlist['sanctuary'][2])#sanctuary spawn point
  4873. self.tilemap[starty-1][startx] = deepcopy(tl.tlist['functional'][20])#divine gift
  4874. self.tilemap[starty-1][startx].replace = tl.tlist['sanctuary'][0]
  4875. self.countdowns.append(countdown('gift_to_workbench',startx,starty-1,1))
  4876. material_pick = random.randint(0,10)
  4877. material_axe = random.randint(0,10)
  4878. material_amo = random.randint(0,10)
  4879. amo_classes = ('shoes','cuisse','armor','helmet')
  4880. ran = random.randint(0,3)
  4881. amo_class = amo_classes[ran]
  4882. pick = item_wear('pickaxe', material_pick,0)
  4883. axe = item_wear('axe',material_axe,0)
  4884. amo = item_wear(amo_class,material_amo,0)
  4885. ran_tunica = random.randint(0,2)
  4886. #original
  4887. self.add_container([pick,axe,amo,il.ilist['misc'][53],il.ilist['misc'][2],il.ilist['misc'][51],il.ilist['clothe'][ran_tunica]],startx,starty-1)
  4888. #/original
  4889. # statue demo:
  4890. #list_t = [pick,axe]
  4891. #for f in range(55,70):
  4892. # list_t.append(il.ilist['misc'][f])
  4893. #self.add_container(list_t,startx,starty-1)
  4894. # build demo: self.add_container([pick,axe,amo,il.ilist['misc'][3],il.ilist['misc'][16],il.ilist['misc'][22],il.ilist['misc'][23],il.ilist['clothe'][ran_tunica]],startx,starty-1)
  4895. # cloth demo: self.add_container([il.ilist['clothe'][8],il.ilist['clothe'][1],il.ilist['clothe'][2],il.ilist['clothe'][3],il.ilist['clothe'][4],il.ilist['clothe'][5],il.ilist['clothe'][6],il.ilist['clothe'][7]],startx,starty-1)
  4896. # magic demo: self.add_container([pick,axe,amo,il.ilist['misc'][81],il.ilist['misc'][24],il.ilist['misc'][24],il.ilist['misc'][24],il.ilist['clothe'][ran_tunica]],startx,starty-1)
  4897. self.tilemap[starty+1][startx] = deepcopy(tl.tlist['functional'][1])#stair down
  4898. self.tilemap[starty+1][startx].damage = -1
  4899. self.tilemap[starty+1][startx].damage_mes = 'Your wounds are cured.'
  4900. self.tilemap[starty+1][startx].build_here = False
  4901. self.tilemap[starty+1][startx].move_group = 'holy'
  4902. class world_class():
  4903. def __init__(self,tilelist):
  4904. global max_map_size
  4905. screen.render_load(0)
  4906. name = save_path + os.sep + 'world.data'
  4907. self.map_size = 52
  4908. self.startx = 26
  4909. self.starty = 26
  4910. try:
  4911. f = open(name, 'rb')
  4912. temp = p.load(f)
  4913. screen.render_load(1)
  4914. self.maplist = temp.maplist
  4915. self.map_size = temp.map_size
  4916. max_map_size = self.map_size
  4917. self.startx = temp.startx
  4918. self.starty = temp.starty
  4919. except:
  4920. screen.render_load(2)
  4921. self.maplist = []
  4922. for x in range (0,7):
  4923. self.maplist.append({})
  4924. screen.render_load(3)
  4925. pos = self.grassland_generator(0,0,30,80,5,int((max_map_size*max_map_size)/20))
  4926. self.startx = 26
  4927. self.starty = 26
  4928. self.cave_generator(2)
  4929. self.border_generator(3)
  4930. screen.render_load(5)
  4931. self.elysium_generator()
  4932. def default_map_generator(self, name, tiles, tilelist): #check if tilelist can be deleted
  4933. tilemap = []
  4934. for i in range (0,max_map_size):
  4935. tilemap.append([])
  4936. a = 0
  4937. for b in range (0,max_map_size):
  4938. ran_num = random.randint(0,len(tl.tlist[tiles])-1)
  4939. tilemap[a].append(tl.tlist[tiles][ran_num])
  4940. b = 0
  4941. for a in range (1,max_map_size):
  4942. ran_num = random.randint(0,len(tl.tlist[tiles])-1)
  4943. tilemap[a].append(tl.tlist[tiles][ran_num])
  4944. for a in range (1,max_map_size):
  4945. for b in range (1,max_map_size):
  4946. ran_same = random.randint(0,9)
  4947. if ran_same < 5 :
  4948. tilemap[a].append(tilemap[a-1][b])
  4949. elif ran_same < 8:
  4950. tilemap[a].append(tilemap[a][b-1])
  4951. else:
  4952. ran_num = random.randint(0,len(tl.tlist[tiles])-1)
  4953. tilemap[a].append(tl.tlist[tiles][ran_num])
  4954. m = maP(name ,tilemap)
  4955. return m
  4956. def border_generator(self,layer,style='default'):
  4957. if style == 'default':
  4958. cave_name = 'local_0_0'
  4959. elif style == 'desert':
  4960. cave_name = 'desert_0_0'
  4961. m = self.default_map_generator(cave_name,'global_caves', tilelist)
  4962. m.map_type = 'border'
  4963. m.fill(tl.tlist['functional'][0])#fill with border
  4964. self.maplist[layer][cave_name] = m
  4965. def grot_generator(self,layer):
  4966. screen.render_load(15,1)
  4967. cave_name = 'dungeon_0_1'
  4968. m = self.default_map_generator(cave_name,'global_caves', tilelist)
  4969. m.map_type = 'grot'
  4970. m.set_music('grot','grot',True)
  4971. m.build_type = 'None'
  4972. m.fill(tl.tlist['global_caves'][3])#fill with hard rock
  4973. m.drunken_walker(int(max_map_size/2),int(max_map_size/2),tl.tlist['misc'][0],(((max_map_size*max_map_size)/100)*40))#set low water
  4974. m.set_frame(tl.tlist['functional'][0])
  4975. chance_ore = layer*5
  4976. chance_gem = layer*3
  4977. screen.render_load(15,10)
  4978. for y in range (0,max_map_size):
  4979. for x in range (0,max_map_size):
  4980. if m.tilemap[y][x].techID == tl.tlist['global_caves'][3].techID:#this is hard rock
  4981. replace = m.tilemap[y][x].replace
  4982. coin = random.randint(0,1)
  4983. percent = random.randint(1,100)
  4984. if coin == 0 and percent <= chance_ore:
  4985. m.tilemap[y][x] = tl.tlist['misc'][4]#set ore here
  4986. m.tilemap[y][x].replace = replace
  4987. elif coin == 1 and percent <= chance_gem:
  4988. m.tilemap[y][x] = tl.tlist['misc'][5]#set gem here
  4989. m.tilemap[y][x].replace = replace
  4990. screen.render_load(15,40)
  4991. for y in range (0,max_map_size):
  4992. for x in range (0,max_map_size):
  4993. if m.tilemap[y][x].techID == tl.tlist['misc'][1].techID:#this is mud
  4994. cent = random.randint(0,99)
  4995. if cent < 10: #its a chance of 10% that a blue mushroom spawns here
  4996. replace = m.tilemap[y][x]
  4997. m.tilemap[y][x] = tl.tlist['misc'][6]
  4998. m.tilemap[y][x].replace = replace
  4999. m.containers[y][x] = container([deepcopy(il.ilist['food'][1])])
  5000. screen.render_load(15,75)
  5001. num_lilys = int(((max_map_size*max_map_size)/100)*3)
  5002. for i in range (0,num_lilys):
  5003. pos = m.find_any(tl.tlist['misc'][0])#find low wather
  5004. try:
  5005. coin = random.randint(0,1)
  5006. if coin == 0:
  5007. m.tilemap[pos[1]][pos[0]] = tl.tlist['misc'][10]#set a water lily
  5008. else:
  5009. m.tilemap[pos[1]][pos[0]] = tl.tlist['misc'][14]#set a water lily with blossom
  5010. except:
  5011. None
  5012. screen.render_load(15,90)
  5013. pos = m.find_any(tl.tlist['misc'][0])#find any low water tile
  5014. m.tilemap[pos[1]][pos[0]] = tl.tlist['dungeon'][15]#set stair up
  5015. entrance_x = pos[0]
  5016. entrance_y = pos[1]
  5017. for sy in range(pos[1]-4,pos[1]+5):
  5018. for sx in range(pos[0]-4,pos[0]+5):
  5019. try:
  5020. if m.tilemap[sy][sx].move_group == 'soil':
  5021. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  5022. m.tilemap[sy][sx].move_group == 'dry_entrance'
  5023. elif m.tilemap[sy][sx].move_group == 'low_liquid':
  5024. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  5025. m.tilemap[sy][sx].move_group == 'wet_entrance'
  5026. except:
  5027. None
  5028. m.make_shops()
  5029. m.spawn_monsters(3)
  5030. screen.render_load(15,99)
  5031. self.maplist[layer][cave_name] = m
  5032. def elfish_generator(self,layer):
  5033. screen.render_load(16,1)
  5034. map_name = 'fortress_0_0'
  5035. m = self.default_map_generator(map_name,'global_caves', tilelist)
  5036. m.map_type = 'elfish_fortress'
  5037. m.set_music('elfish_fortress','elfish_fortress',True)
  5038. m.no_monster_respawn = True
  5039. m.build_type = 'None'
  5040. m.fill(tl.tlist['elfish'][0])
  5041. for y in range (10, max_map_size-10,10):
  5042. ran = random.randint(0,3)
  5043. for yy in range (y-1,y+2):
  5044. if ran < 3:
  5045. m.imp_connect((0,max_map_size-1),(yy,yy),tl.tlist['elfish'][1],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  5046. if ran < 3:
  5047. m.imp_connect((0,max_map_size-1),(y-2,y-2),tl.tlist['elfish'][3],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  5048. m.imp_connect((0,max_map_size-1),(y+2,y+2),tl.tlist['elfish'][3],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  5049. screen.render_load(16,10)
  5050. for x in range (10, max_map_size-10,10):
  5051. ran = random.randint(0,3)
  5052. for xx in range (x-1,x+2):
  5053. if ran < 3:
  5054. m.imp_connect((xx,xx),(0,max_map_size-1),tl.tlist['elfish'][1],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  5055. if ran < 3:
  5056. m.imp_connect((x-2,x-2),(0,max_map_size-1),tl.tlist['elfish'][3],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  5057. m.imp_connect((x+2,x+2),(0,max_map_size-1),tl.tlist['elfish'][3],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  5058. m.cut(2,max_map_size-3,2,max_map_size-3,tl.tlist['elfish'][3])
  5059. building_count = 0
  5060. run = True
  5061. screen.render_load(16,30)
  5062. while run:
  5063. pos=m.find_first(tl.tlist['elfish'][0])
  5064. if pos != False:
  5065. m.floating(pos[0],pos[1],tl.tlist['elfish'][5],tl.tlist['elfish'][3])#fill with help passive
  5066. building_count += 1
  5067. else:
  5068. run = False
  5069. m.exchange(tl.tlist['elfish'][5],tl.tlist['elfish'][0])
  5070. screen.render_load(16,50)
  5071. if building_count < 6:
  5072. return False #return false to make a loop if there are to less buildings inside the map
  5073. num_temples = int((float(building_count)/100)*10)
  5074. if num_temples == 0:
  5075. num_temples = 1
  5076. num_agriculture = int((float(building_count)/100)*10)
  5077. if num_agriculture == 0:
  5078. num_agriculture=1
  5079. num_meetingarea = int((float(building_count)/100)*10)
  5080. if num_meetingarea == 0:
  5081. num_meetingarea = 1
  5082. num_marketplace = int((float(building_count)/100)*10)
  5083. if num_marketplace == 0:
  5084. num_marketplace = 1
  5085. num_libaries = int((float(building_count)/100)*10)
  5086. if num_libaries == 0:
  5087. num_libaries = 1
  5088. num_dwellings = building_count-num_temples-num_agriculture-num_meetingarea-num_marketplace-num_libaries
  5089. screen.render_load(16,60)
  5090. m.cut(2,max_map_size-3,2,max_map_size-3,tl.tlist['elfish'][1])
  5091. for i in range(0,num_agriculture):
  5092. pos = m.find_any(tl.tlist['elfish'][0])#find any elfish_floor_indoor
  5093. m.floating(pos[0],pos[1],tl.tlist['elfish'][2],tl.tlist['elfish'][1])#replace this building with elfish_agriculture
  5094. for y in range(0,max_map_size,2):
  5095. for x in range(0,max_map_size):
  5096. if m.tilemap[y][x].techID == tl.tlist['elfish'][2].techID:#this is elfish agriculture
  5097. m.tilemap[y][x] = tl.tlist['misc'][0]#set low water
  5098. for y in range(0,max_map_size):
  5099. for x in range(0,max_map_size):
  5100. if m.tilemap[y][x].techID == tl.tlist['elfish'][2].techID:#this is elfish agriculture
  5101. coin = random.randint(0,10)
  5102. if coin == 1:
  5103. m.npcs[y][x] = deepcopy(ml.mlist['elfish_special'][2])#elfish farmer
  5104. m.set_monster_strength(x,y,1,lvl_bonus=5)
  5105. screen.render_load(16,65)
  5106. m.cut(2,max_map_size-3,2,max_map_size-3,tl.tlist['elfish'][3])
  5107. for i in range(0,num_marketplace):#set marketplaces
  5108. pos = m.find_any(tl.tlist['elfish'][0])#find any elfish_floor_indoor
  5109. m.floating(pos[0],pos[1],tl.tlist['elfish'][4],tl.tlist['elfish'][3])#fill this building with elfish_active
  5110. pos = m.find_first(tl.tlist['elfish'][4])
  5111. size = m.get_quarter_size(pos[0],pos[1])
  5112. for y in range(pos[1]+1,pos[1]+size[1]-1,2):
  5113. for x in range(pos[0]+1,pos[0]+size[0]-1,3):
  5114. m.npcs[y][x] = ml.mlist['shop'][0]
  5115. m.set_monster_strength(x,y,5)
  5116. m.exchange(tl.tlist['elfish'][4],tl.tlist['shop'][0])
  5117. screen.render_load(16,70)
  5118. for i in range(0,num_temples):
  5119. pos = m.find_any(tl.tlist['elfish'][0])#find any elfish_floor_indoor
  5120. m.floating(pos[0],pos[1],tl.tlist['elfish'][4],tl.tlist['elfish'][3])#fill this building with elfish_active
  5121. pos = m.find_first(tl.tlist['elfish'][4])
  5122. size = m.get_quarter_size(pos[0],pos[1])
  5123. for y in range(pos[1],pos[1]+size[1],2):
  5124. for x in range(pos[0],pos[0]+size[0],2):
  5125. m.tilemap[y][x] = deepcopy(tl.tlist['functional'][22])
  5126. m.tilemap[y][x].replace = tl.tlist['elfish'][0]
  5127. m.tilemap[y][x].civilisation = False
  5128. m.tilemap[pos[1]+int(size[1]/2)][pos[0]+int(size[0]/2)] = deepcopy(tl.tlist['functional'][15])#set a altar
  5129. m.tilemap[pos[1]+int(size[1]/2)][pos[0]+int(size[0]/2)].replace = tl.tlist['elfish'][0]
  5130. m.tilemap[pos[1]+int(size[1]/2)][pos[0]+int(size[0]/2)].civilisation = False
  5131. m.npcs[pos[1]+int(size[1]/2)][pos[0]+int(size[0]/2)] = deepcopy(ml.mlist['elfish_special'][3])
  5132. m.set_monster_strength(pos[0]+int(size[0]/2),pos[1]+int(size[1]/2),1,lvl_bonus=5)
  5133. m.exchange(tl.tlist['elfish'][4],tl.tlist['elfish'][5])
  5134. screen.render_load(16,75)
  5135. for i in range(0,num_meetingarea):
  5136. pos = m.find_any(tl.tlist['elfish'][0])
  5137. m.floating(pos[0],pos[1],tl.tlist['elfish'][4],tl.tlist['elfish'][3])#fill this building with elfish_active
  5138. pos = m.find_first(tl.tlist['elfish'][4])
  5139. size = m.get_quarter_size(pos[0],pos[1])
  5140. m.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['elfish_special'][0]) #set elfish landlord
  5141. m.set_monster_strength(pos[0],pos[1],1,lvl_bonus=5)
  5142. for y in range(pos[1]+2,pos[1]+size[1]-2):
  5143. for x in range(pos[0]+2,pos[0]+size[0]-1,4):
  5144. m.tilemap[y][x] = deepcopy(tl.tlist['functional'][16]) #set table
  5145. m.tilemap[y][x].replace = tl.tlist['elfish'][0]
  5146. m.tilemap[y][x].civilisation = False
  5147. for xx in range(x-1,x+2):
  5148. if m.tilemap[y][xx].techID == tl.tlist['elfish'][4].techID:
  5149. m.tilemap[y][xx] = deepcopy(tl.tlist['functional'][18])
  5150. m.tilemap[y][xx].replace = tl.tlist['elfish'][0]
  5151. m.tilemap[y][xx].civilisation = False
  5152. coin = random.randint(0,3)
  5153. if coin == 1:
  5154. m.npcs[y][xx] = deepcopy(ml.mlist['elfish_special'][1]) #set elfish drunkard
  5155. m.set_monster_strength(xx,y,1,lvl_bonus=5)
  5156. for yy in range(y-1,y+2):
  5157. if m.tilemap[yy][x].techID == tl.tlist['elfish'][4].techID:
  5158. m.tilemap[yy][x] = deepcopy(tl.tlist['functional'][18])
  5159. m.tilemap[yy][x].replace = tl.tlist['elfish'][0]
  5160. m.tilemap[yy][x].civilisation = False
  5161. coin = random.randint(0,3)
  5162. if coin == 1:
  5163. m.npcs[yy][x] = deepcopy(ml.mlist['elfish_special'][1]) #set elfish drunkard
  5164. m.set_monster_strength(x,yy,1,lvl_bonus=5)
  5165. m.exchange(tl.tlist['elfish'][4],tl.tlist['elfish'][5])
  5166. screen.render_load(16,80)
  5167. for i in range(0,num_libaries):
  5168. pos = m.find_any(tl.tlist['elfish'][0])
  5169. m.floating(pos[0],pos[1],tl.tlist['elfish'][4],tl.tlist['elfish'][3])#fill this building with elfish_active
  5170. pos = m.find_first(tl.tlist['elfish'][4])
  5171. size = m.get_quarter_size(pos[0],pos[1])
  5172. for y in range(pos[1]+1,pos[1]+size[1]-1,2):
  5173. for x in range(pos[0]+1,pos[0]+size[0]-1,2):
  5174. m.tilemap[y][x] = deepcopy(tl.tlist['functional'][19])
  5175. m.tilemap[y][x].civilisation = False
  5176. lillya_pos = m.find_any(tl.tlist['functional'][19]) #set lillya
  5177. m.npcs[lillya_pos[1]+1][lillya_pos[0]] = deepcopy(ml.mlist['rescued'][2])
  5178. m.set_monster_strength(lillya_pos[0],lillya_pos[1],1)
  5179. m.exchange(tl.tlist['elfish'][4],tl.tlist['elfish'][5])
  5180. screen.render_load(16,85)
  5181. for i in range(0,num_dwellings):
  5182. pos = m.find_any(tl.tlist['elfish'][0])
  5183. m.floating(pos[0],pos[1],tl.tlist['elfish'][4],tl.tlist['elfish'][3])#fill this building with elfish_active
  5184. pos = m.find_first(tl.tlist['elfish'][4])
  5185. pos_original = pos
  5186. size = m.get_quarter_size(pos[0],pos[1])
  5187. num_beds = int((size[0]*size[1])/9)
  5188. num_furniture = int((size[0]*size[1])/25)
  5189. for y in range(pos[1],pos[1]+size[1]):
  5190. for x in range(pos[0],pos[0]+size[0]):
  5191. m.tilemap[y][x] = tl.tlist['elfish'][5]
  5192. for y in range(pos[1]+1,pos[1]+size[1]-1):
  5193. for x in range(pos[0]+1,pos[0]+size[0]-1):
  5194. m.tilemap[y][x] = tl.tlist['elfish'][4]
  5195. for i in range(0,num_beds):#set beds
  5196. pos = m.find_any(tl.tlist['elfish'][4])
  5197. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['functional'][8])
  5198. m.tilemap[pos[1]][pos[0]].replace = deepcopy(tl.tlist['building'][9])
  5199. m.tilemap[pos[1]][pos[0]].civilisation = False
  5200. m.tilemap[pos[1]][pos[0]].replace.civilisation = False
  5201. for i in range(0,num_furniture):#set furnaces
  5202. pos = m.find_any(tl.tlist['elfish'][4])
  5203. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['functional'][14])
  5204. m.tilemap[pos[1]][pos[0]].replace = deepcopy(tl.tlist['building'][9])
  5205. m.tilemap[pos[1]][pos[0]].civilisation = False
  5206. m.tilemap[pos[1]][pos[0]].replace.civilisation = False
  5207. for i in range(0,num_furniture):#set wb's
  5208. pos = m.find_any(tl.tlist['elfish'][4])
  5209. ran = random.randint(9,13)
  5210. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['functional'][ran])
  5211. m.tilemap[pos[1]][pos[0]].replace = deepcopy(tl.tlist['building'][9])
  5212. m.tilemap[pos[1]][pos[0]].civilisation = False
  5213. m.tilemap[pos[1]][pos[0]].replace.civilisation = False
  5214. for y in range(pos_original[1]+1,pos_original[1]+size[1]-1):#set blue floor
  5215. for x in range(pos_original[0]+1,pos_original[0]+size[0]-1):
  5216. if m.tilemap[y][x].techID == tl.tlist['elfish'][4].techID:
  5217. m.tilemap[y][x] = deepcopy(tl.tlist['building'][9])
  5218. m.tilemap[y][x].civilisation = False
  5219. screen.render_load(16,90)
  5220. for yy in range(0,max_map_size,5):
  5221. for xx in range(0,max_map_size):
  5222. if m.tilemap[yy][xx].techID == tl.tlist['elfish'][3].techID:#this is elfish wall
  5223. m.tilemap[yy][xx] = deepcopy(tl.tlist['building'][2]) #set a open door here
  5224. m.tilemap[yy][xx].civilisation = False
  5225. for yyy in range(yy-1,yy+2):
  5226. for xxx in range(xx-1,xx+2):
  5227. if yyy >= 0 and xxx >= 0 and xxx < max_map_size and yyy < max_map_size:
  5228. if m.tilemap[yyy][xxx].techID != tl.tlist['elfish'][0].techID and m.tilemap[yyy][xxx].techID != tl.tlist['elfish'][1].techID and m.tilemap[yyy][xxx].techID != tl.tlist['shop'][0].techID and m.tilemap[yyy][xxx].techID != tl.tlist['building'][2].techID and m.tilemap[yyy][xxx].techID != tl.tlist['elfish'][3].techID and m.tilemap[yyy][xxx].techID != tl.tlist['elfish'][2].techID and m.tilemap[yyy][xxx].techID != tl.tlist['misc'][0].techID:
  5229. #if a field next to a door isn't elfish_indoor, elfish_wall or shop_floor set it to elfish_indoor
  5230. m.tilemap[yyy][xxx] = tl.tlist['elfish'][0]
  5231. screen.render_load(16,95)
  5232. for yy in range(0,max_map_size):
  5233. for xx in range(0,max_map_size,5):
  5234. if m.tilemap[yy][xx].techID == tl.tlist['elfish'][3].techID:#this is elfish wall
  5235. m.tilemap[yy][xx] = deepcopy(tl.tlist['building'][2]) #set a open door here
  5236. m.tilemap[yy][xx].civilisation = False
  5237. for yyy in range(yy-1,yy+2):
  5238. for xxx in range(xx-1,xx+2):
  5239. if yyy >= 0 and xxx >= 0 and xxx < max_map_size and yyy < max_map_size:
  5240. if m.tilemap[yyy][xxx].techID != tl.tlist['elfish'][0].techID and m.tilemap[yyy][xxx].techID != tl.tlist['elfish'][1].techID and m.tilemap[yyy][xxx].techID != tl.tlist['shop'][0].techID and m.tilemap[yyy][xxx].techID != tl.tlist['building'][2].techID and m.tilemap[yyy][xxx].techID != tl.tlist['elfish'][3].techID and m.tilemap[yyy][xxx].techID != tl.tlist['elfish'][2].techID and m.tilemap[yyy][xxx].techID != tl.tlist['misc'][0].techID:
  5241. #if a field next to a door isn't elfish_indoor, elfish_wall or shop_floor set it to elfish_indoor
  5242. m.tilemap[yyy][xxx] = tl.tlist['elfish'][0]
  5243. screen.render_load(16,97)
  5244. m.cut(2,max_map_size-3,2,max_map_size-3,tl.tlist['elfish'][3])
  5245. m.set_frame(tl.tlist['functional'][0])
  5246. #set fontains
  5247. for y in range(10,max_map_size-10,10):
  5248. for x in range(10,max_map_size-10,10):
  5249. if m.tilemap[y][x].techID == tl.tlist['elfish'][1].techID:
  5250. coin = random.randint(0,1)
  5251. if coin == 0:
  5252. m.tilemap[y][x] = deepcopy(tl.tlist['functional'][7])#set a fontain
  5253. m.tilemap[y][x].replace = tl.tlist['elfish'][1]
  5254. m.tilemap[y][x].civilisation = False #this is no players fontain
  5255. m.exchange(tl.tlist['elfish'][5],tl.tlist['elfish'][0])
  5256. pos = m.find_any(tl.tlist['functional'][7]) #set portal home
  5257. if pos == False:
  5258. pos = m.find_any(tl.tlist['elfish'][1])
  5259. for xy in range(0,max_map_size):
  5260. if m.tilemap[xy][pos[0]].techID == tl.tlist['elfish'][1].techID:
  5261. m.tilemap[xy][pos[0]] = deepcopy(tl.tlist['elfish'][7])
  5262. try:
  5263. if m.tilemap[xy][pos[0]].replace.techID == tl.tlist['elfish'][1].techID:
  5264. m.tilemap[xy][pos[0]].replace = deepcopy(tl.tlist['elfish'][7])
  5265. except:
  5266. None
  5267. if m.tilemap[pos[1]][xy].techID == tl.tlist['elfish'][1].techID:
  5268. m.tilemap[pos[1]][xy] = deepcopy(tl.tlist['elfish'][7])
  5269. try:
  5270. if m.tilemap[pos[1]][xy].replace.techID == tl.tlist['elfish'][1].techID:
  5271. m.tilemap[pos[1]][xy].replace = deepcopy(tl.tlist['elfish'][7])
  5272. except:
  5273. None
  5274. replace = deepcopy(tl.tlist['elfish'][7])
  5275. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['portal'][2])
  5276. m.tilemap[pos[1]][pos[0]].replace = replace
  5277. m.spawn_monsters(6)
  5278. self.maplist[layer][map_name] = m
  5279. screen.render_load(16,00)
  5280. def mine_generator(self,layer):
  5281. screen.render_load(17,1)
  5282. cave_name = 'dungeon_0_1'
  5283. m = self.default_map_generator(cave_name,'global_caves', tilelist)
  5284. m.map_type = 'orcish_mines'
  5285. m.set_music('orcish_mines','orcish_mines',True)
  5286. m.build_type = 'None'
  5287. m.monster_plus = 9
  5288. screen.render_load(17,10)
  5289. m.fill(tl.tlist['mine'][1])#fill with mine wall
  5290. screen.render_load(17,30)
  5291. m.drunken_walker(int(max_map_size/2),int(max_map_size/2),tl.tlist['mine'][0],((max_map_size**2/100)*45))
  5292. screen.render_load(17,50)
  5293. screen.render_load(17,60)
  5294. m.exchange_when_surrounded(tl.tlist['mine'][1],tl.tlist['global_caves'][3],8) #only the outer tiles become mine wall
  5295. screen.render_load(17,70)
  5296. for y in range (0, max_map_size):
  5297. for x in range(0,max_map_size):
  5298. if m.tilemap[y][x].techID == tl.tlist['global_caves'][3].techID:#this is hard rock
  5299. ran = random.randint(0,99)
  5300. if ran > 69:
  5301. m.tilemap[y][x] = tl.tlist['misc'][4]#set ore
  5302. m.tilemap[y][x].replace = tl.tlist['global_caves'][0]
  5303. elif ran < 10:
  5304. m.tilemap[y][x] = tl.tlist['misc'][5]#set gem
  5305. m.tilemap[y][x].replace = tl.tlist['global_caves'][0]
  5306. screen.render_load(17,80)
  5307. m.set_frame(tl.tlist['functional'][0])
  5308. m.make_shops()
  5309. m.make_containers(15,30,tl.tlist['mine'][0],1,4,'remains')
  5310. num_moss = int(((max_map_size*max_map_size)/100)*3)
  5311. for i in range (0,num_moss):
  5312. pos = m.find_any(tl.tlist['mine'][0])#find mine floor
  5313. try:
  5314. m.tilemap[pos[1]][pos[0]] = tl.tlist['mine'][2]#set blood moss
  5315. except:
  5316. None
  5317. screen.render_load(17,90)
  5318. pos = m.find_any(tl.tlist['mine'][0])#find any mine floor tile
  5319. m.tilemap[pos[1]][pos[0]] = tl.tlist['dungeon'][17]#set stair up
  5320. entrance_x = pos[0]
  5321. entrance_y = pos[1]
  5322. for sy in range(pos[1]-4,pos[1]+5):
  5323. for sx in range(pos[0]-4,pos[0]+5):
  5324. try:
  5325. if m.tilemap[sy][sx].move_group == 'soil':
  5326. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  5327. m.tilemap[sy][sx].move_group == 'dry_entrance'
  5328. elif m.tilemap[sy][sx].move_group == 'low_liquid':
  5329. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  5330. m.tilemap[sy][sx].move_group == 'wet_entrance'
  5331. except:
  5332. None
  5333. m.spawn_monsters(9)
  5334. screen.render_load(17,99)
  5335. self.maplist[layer][cave_name] = m
  5336. def cave_generator(self, deep, style='default'):
  5337. if style == 'desert':
  5338. cave_name='desert_0_0'
  5339. else:
  5340. cave_name = 'local_0_0'
  5341. p = 9
  5342. for d in range(1,deep+2):
  5343. screen.render_load(4,p+(d*20))
  5344. m = self.default_map_generator(cave_name,'global_caves', tilelist)
  5345. if d < 2:
  5346. if style == 'desert':
  5347. m.map_type = 'desert_cave'
  5348. m.monster_plus = 7
  5349. else:
  5350. m.map_type = 'cave'
  5351. m.set_music('cave','cave',True)
  5352. else:
  5353. if style == 'desert':
  5354. m.map_type = 'desert_lava_cave'
  5355. m.monster_plus = 7
  5356. else:
  5357. m.map_type = 'lava_cave'
  5358. m.set_music('lava_cave','lava_cave',True)
  5359. m.thirst_multi_day = 2
  5360. m.thirst_multi_night = 2
  5361. if d > 1:
  5362. m.exchange(tl.tlist['global_caves'][4],tl.tlist['misc'][2])#exchange lava against hot cave ground
  5363. m.exchange(tl.tlist['global_caves'][1],tl.tlist['misc'][28])#exchange worn rock against obsidian
  5364. if d > 1:
  5365. m.exchange_when_surrounded(tl.tlist['misc'][2],tl.tlist['global_caves'][4],8)#make lava spots between hot cave ground
  5366. num = int((max_map_size*max_map_size)/(50*50))
  5367. for i in range(0,num):
  5368. ran = random.randint(0,1)
  5369. if ran > 0:
  5370. pos = m.find_any(tl.tlist['global_caves'][0]) #cave ground
  5371. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['functional'][23])# make master forges
  5372. else:
  5373. m.exchange(tl.tlist['global_caves'][4],tl.tlist['misc'][1])#exchange lava against mud
  5374. m.exchange_when_surrounded(tl.tlist['misc'][1],tl.tlist['misc'][0],8)#make low water spots between mud
  5375. #######set mushrooms, ore and gems
  5376. chance_ore = d*2
  5377. chance_gem = d
  5378. for y in range (0,max_map_size):
  5379. for x in range (0,max_map_size):
  5380. if m.tilemap[y][x].techID == tl.tlist['global_caves'][3].techID:#this is hard rock
  5381. replace = m.tilemap[y][x].replace
  5382. coin = random.randint(0,1)
  5383. percent = random.randint(1,100)
  5384. if coin == 0 and percent <= chance_ore:
  5385. m.tilemap[y][x] = tl.tlist['misc'][4]#set ore here
  5386. m.tilemap[y][x].replace = replace
  5387. elif coin == 1 and percent <= chance_gem:
  5388. m.tilemap[y][x] = tl.tlist['misc'][5]#set gem here
  5389. m.tilemap[y][x].replace = replace
  5390. if m.tilemap[y][x].techID == tl.tlist['misc'][1].techID:#this is mud
  5391. cent = random.randint(0,99)
  5392. if cent < 10: #its a chance of 10% that a blue mushroom spawns here
  5393. replace = m.tilemap[y][x]
  5394. m.tilemap[y][x] = tl.tlist['misc'][6]
  5395. m.tilemap[y][x].replace = replace
  5396. if m.tilemap[y][x].techID == tl.tlist['global_caves'][0].techID:#this is cave ground
  5397. cent = random.randint(0,99)
  5398. if cent < 10: #its a chance of 10% that a brown mushroom spawns here
  5399. replace = m.tilemap[y][x]
  5400. m.tilemap[y][x] = tl.tlist['misc'][7]
  5401. m.tilemap[y][x].replace = replace
  5402. elif cent < 15: #its a chance of 5% that a purple mushroom spawns here
  5403. replace = m.tilemap[y][x]
  5404. m.tilemap[y][x] = tl.tlist['misc'][8]
  5405. m.tilemap[y][x].replace = replace
  5406. m.set_frame(tl.tlist['functional'][0])
  5407. if d == 1 and style == 'default':#set stair up on lvl 1
  5408. pos = (int(max_map_size/2),int(max_map_size/2))
  5409. m.tilemap[pos[1]+1][pos[0]] = deepcopy(tl.tlist['functional'][2])#stair down
  5410. m.tilemap[pos[1]+1][pos[0]].damage = -1
  5411. m.tilemap[pos[1]+1][pos[0]].damage_mes = 'Your wounds are cured.'
  5412. m.tilemap[pos[1]+1][pos[0]].build_here = False
  5413. for yy in range(pos[1]-3,pos[1]+4):
  5414. for xx in range(pos[0]-3,pos[0]+4):
  5415. m.tilemap[yy][xx].no_spawn = True
  5416. for x in range(0,max_map_size):
  5417. if m.tilemap[x][pos[0]].techID == tl.tlist['global_caves'][3].techID:#this is hard rock
  5418. ran = random.randint(1,2)
  5419. m.tilemap[x][pos[0]] = deepcopy(tl.tlist['global_caves'][ran])
  5420. for y in range(0,max_map_size):
  5421. if m.tilemap[pos[1]+1][y].techID == tl.tlist['global_caves'][3].techID:#this is hard rock
  5422. ran = random.randint(1,2)
  5423. m.tilemap[pos[1]+1][y] = deepcopy(tl.tlist['global_caves'][ran])
  5424. #set vaults
  5425. for i in range(0,int(max_map_size**2/50**2)):
  5426. m.make_vault(tl.tlist['global_caves'][0],d)
  5427. for j in range(0,15):
  5428. pos = m.find_any(tl.tlist['global_caves'][0])
  5429. m.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['statue'][1])
  5430. m.npcs[pos[1]][pos[0]].lp = 999
  5431. m.npcs[pos[1]][pos[0]].basic_attribute.max_lp = 999
  5432. #set grot/mine at lvl 1 and 3
  5433. #if style == 'default':
  5434. # if d == 1:
  5435. # ran_pos = m.find_any(tl.tlist['global_caves'][0])
  5436. # m.tilemap[ran_pos[1]][ran_pos[0]] = tl.tlist['dungeon'][14]
  5437. #if style == 'desert':
  5438. # if d == 3:
  5439. # ran_pos = m.find_any(tl.tlist['global_caves'][0])
  5440. # m.tilemap[ran_pos[1]][ran_pos[0]] = tl.tlist['dungeon'][16]
  5441. m.make_containers(1,2,tl.tlist['global_caves'][0],2,5,'chest')#set some chests
  5442. m.make_special_monsters(0,1,tl.tlist['global_caves'][0],d,'mimic')#maybe set some mimics
  5443. m.make_special_monsters(15,25,tl.tlist['global_caves'][0],d,'vase')#set some vases
  5444. if m.map_type == 'desert_lava_cave':
  5445. m.make_special_monsters(1,2,tl.tlist['global_caves'][0],d,'demonic chest')#maybe set some demonic chests
  5446. m.spawn_monsters(d)
  5447. if style == 'desert': #replace rock etc.
  5448. for y in range(0,max_map_size):
  5449. for x in range(0,max_map_size):
  5450. if m.tilemap[y][x].techID == tl.tlist['global_caves'][3].techID: #this is hard rock
  5451. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][24])
  5452. elif m.tilemap[y][x].techID == tl.tlist['global_caves'][1].techID: #this is worn rock
  5453. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][23])
  5454. elif m.tilemap[y][x].techID == tl.tlist['global_caves'][2].techID: #this is soft soil
  5455. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][23])
  5456. elif m.tilemap[y][x].techID == tl.tlist['misc'][4].techID: #this is ore
  5457. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][21])
  5458. elif m.tilemap[y][x].techID == tl.tlist['misc'][5].techID: #this is gem
  5459. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][22])
  5460. elif m.tilemap[y][x].techID == tl.tlist['misc'][7].techID: #this is a brown mushroom
  5461. replace = m.tilemap[y][x].replace
  5462. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][25])
  5463. m.tilemap[y][x].replace = replace
  5464. elif m.tilemap[y][x].techID == tl.tlist['misc'][8].techID: #this is a purple mushroom
  5465. replace = m.tilemap[y][x].replace
  5466. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][27])
  5467. m.tilemap[y][x].replace = replace
  5468. elif m.tilemap[y][x].techID == tl.tlist['misc'][6].techID: #this is a blue mushroom
  5469. replace = m.tilemap[y][x].replace
  5470. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][26])
  5471. m.tilemap[y][x].replace = replace
  5472. self.maplist[d][cave_name] = m
  5473. def elysium_generator(self):
  5474. name = 'elysium_0_0'
  5475. tilemap = []
  5476. for a in range (0,max_map_size):
  5477. tilemap.append([])
  5478. for b in range (0,max_map_size):
  5479. tilemap[a].append(0)
  5480. m = maP(name,tilemap)
  5481. m.map_type = 'elysium'
  5482. m.set_music('menu','menu',True)
  5483. m.build_type = 'None'
  5484. m.fill(tl.tlist['sanctuary'][0])
  5485. for x in range(0,max_map_size):
  5486. for y in range(0,max_map_size):
  5487. if x%2 == 0 and y%2 == 0:
  5488. m.tilemap[y][x] = deepcopy(tl.tlist['sanctuary'][1])
  5489. elif x%2 != 0 and y%2 != 0:
  5490. m.tilemap[y][x] = deepcopy(tl.tlist['sanctuary'][1])
  5491. center = int(max_map_size/2)
  5492. for yy in range(center-2,center+3):
  5493. for xx in range(center-2,center+3):
  5494. m.tilemap[yy][xx] = deepcopy(tl.tlist['sanctuary'][0])
  5495. m.tilemap[center][center] = deepcopy(tl.tlist['sanctuary'][2])
  5496. for yyy in range(center-7,center-3):
  5497. for xxx in range(center-2,center+3):
  5498. m.tilemap[yyy][xxx] = deepcopy(tl.tlist['sanctuary'][0])
  5499. for yyy in range(center-2,center+3):
  5500. for xxx in range(center-7,center-3):
  5501. m.tilemap[yyy][xxx] = deepcopy(tl.tlist['sanctuary'][0])
  5502. for yyy in range(center-2,center+3):
  5503. for xxx in range(center+4,center+8):
  5504. m.tilemap[yyy][xxx] = deepcopy(tl.tlist['sanctuary'][0])
  5505. for yyy in range(center+4,center+8):
  5506. for xxx in range(center-2,center+3):
  5507. m.tilemap[yyy][xxx] = deepcopy(tl.tlist['sanctuary'][0])
  5508. help_map = deepcopy(m)
  5509. for yyy in range(0,max_map_size):
  5510. for xxx in range(0,max_map_size):
  5511. if m.tilemap[yyy][xxx].techID == tl.tlist['sanctuary'][0].techID:
  5512. count = 0
  5513. for yyyy in range(yyy-1,yyy+2):
  5514. for xxxx in range(xxx-1,xxx+2):
  5515. try:
  5516. if m.tilemap[yyyy][xxxx].techID == tl.tlist['sanctuary'][1].techID:
  5517. count += 1
  5518. except:
  5519. None
  5520. if count == 4:
  5521. help_map.tilemap[yyy][xxx] = deepcopy(tl.tlist['sanctuary'][1])
  5522. m = help_map
  5523. m.tilemap[center][center-1] = deepcopy(tl.tlist['sanctuary'][3])
  5524. m.tilemap[center][center+1] = deepcopy(tl.tlist['sanctuary'][3])
  5525. m.tilemap[center][center-5] = deepcopy(tl.tlist['sanctuary'][3])
  5526. m.tilemap[center][center+5] = deepcopy(tl.tlist['sanctuary'][3])
  5527. m.tilemap[center][center-1] = deepcopy(tl.tlist['sanctuary'][3])
  5528. m.tilemap[center-5][center] = deepcopy(tl.tlist['sanctuary'][3])
  5529. m.tilemap[center-7][center] = deepcopy(tl.tlist['portal'][6])
  5530. m.tilemap[center-7][center].replace = deepcopy(tl.tlist['sanctuary'][0])
  5531. m.tilemap[center-8][center+1] = deepcopy(tl.tlist['portal'][0])
  5532. m.tilemap[center-8][center+1].replace = deepcopy(tl.tlist['sanctuary'][0])
  5533. m.tilemap[center-8][center-1] = deepcopy(tl.tlist['portal'][3])
  5534. m.tilemap[center-8][center-1].replace = deepcopy(tl.tlist['sanctuary'][0])
  5535. #set nest boxes
  5536. m.tilemap[23][30] = deepcopy(tl.tlist['sanctuary'][4])
  5537. m.tilemap[23][30].replace = deepcopy(tl.tlist['sanctuary'][0])
  5538. m.tilemap[23][32] = deepcopy(tl.tlist['sanctuary'][4])
  5539. m.tilemap[23][32].replace = deepcopy(tl.tlist['sanctuary'][0])
  5540. m.tilemap[25][34] = deepcopy(tl.tlist['sanctuary'][4])
  5541. m.tilemap[25][34].replace = deepcopy(tl.tlist['sanctuary'][0])
  5542. m.tilemap[27][34] = deepcopy(tl.tlist['sanctuary'][4])
  5543. m.tilemap[27][34].replace = deepcopy(tl.tlist['sanctuary'][0])
  5544. m.tilemap[29][32] = deepcopy(tl.tlist['sanctuary'][4])
  5545. m.tilemap[29][32].replace = deepcopy(tl.tlist['sanctuary'][0])
  5546. m.tilemap[29][30] = deepcopy(tl.tlist['sanctuary'][4])
  5547. m.tilemap[29][30].replace = deepcopy(tl.tlist['sanctuary'][0])
  5548. #set tutorial npcs
  5549. m.npcs[center-3][center-6] = deepcopy(ml.mlist['seraph'][0])
  5550. m.set_monster_strength(center-6,center-3,1)
  5551. m.npcs[center-3][center-6].lp = 999
  5552. m.npcs[center][center+6] = deepcopy(ml.mlist['seraph'][1])
  5553. m.set_monster_strength(center+6,center,1)
  5554. m.npcs[center][center+6].lp = 999
  5555. m.npcs[center+4][center-3] = deepcopy(ml.mlist['seraph'][2])
  5556. m.set_monster_strength(center-3,center+4,1)
  5557. m.npcs[center+4][center-3].lp = 999
  5558. m.npcs[center+4][center+3] = deepcopy(ml.mlist['seraph'][3])
  5559. m.set_monster_strength(center+3,center+4,1)
  5560. m.npcs[center+4][center+3].lp = 999
  5561. m.npcs[center-3][center-4] = deepcopy(ml.mlist['seraph'][4])
  5562. m.set_monster_strength(center-4,center-3,1)
  5563. m.npcs[center-3][center-4].lp = 999
  5564. m.npcs[center+8][center+1] = deepcopy(ml.mlist['seraph'][5])
  5565. m.set_monster_strength(center+1,center+8,1)
  5566. m.npcs[center+8][center+1].lp = 999
  5567. m.npcs[center-6][center] = deepcopy(ml.mlist['seraph'][6])
  5568. m.set_monster_strength(center,center-6,1)
  5569. m.npcs[center-6][center].lp = 999
  5570. m.npcs[center+6][center+3] = deepcopy(ml.mlist['seraph'][7])
  5571. m.set_monster_strength(center+3,center+6,1)
  5572. m.npcs[center+6][center+3].lp = 999
  5573. m.tilemap[center+8][center-1] = deepcopy(tl.tlist['functional'][9]) #carpenters workbench
  5574. m.tilemap[center+8][center-1].replace = tl.tlist['sanctuary'][0] #
  5575. m.tilemap[center+6][center] = deepcopy(tl.tlist['functional'][16]) #table
  5576. m.tilemap[center+6][center].replace = tl.tlist['sanctuary'][0] #
  5577. m.tilemap[center+5][center] = deepcopy(tl.tlist['functional'][18]) #stone seat
  5578. m.tilemap[center+5][center].use_group = 'None' #
  5579. m.tilemap[center+5][center].replace = tl.tlist['sanctuary'][0] #
  5580. m.tilemap[center+7][center] = deepcopy(tl.tlist['functional'][18]) #stone seat
  5581. m.tilemap[center+7][center].use_group = 'None' #
  5582. m.tilemap[center+7][center].replace = tl.tlist['sanctuary'][0] #
  5583. m.tilemap[center+6][center+1] = deepcopy(tl.tlist['functional'][18]) #stone seat
  5584. m.tilemap[center+6][center+1].use_group = 'None' #
  5585. m.tilemap[center+6][center+1].replace = tl.tlist['sanctuary'][0] #
  5586. m.tilemap[center+6][center-1] = deepcopy(tl.tlist['functional'][18]) #stone seat
  5587. m.tilemap[center+6][center-1].use_group = 'None' #
  5588. m.tilemap[center+6][center-1].replace = tl.tlist['sanctuary'][0] #
  5589. self.maplist[0][name] = m
  5590. def grassland_generator(self,x,y,chance_scrubs, chance_trees, chance_herbs, number_rocks):
  5591. # chance_scrubs and chance_trees must be between 0 and 99
  5592. screen.render_load(3,1)
  5593. name = 'local_0_0'
  5594. helpmap = self.default_map_generator('1','help',tilelist)
  5595. tilemap = []
  5596. for a in range (0,max_map_size):
  5597. tilemap.append([])
  5598. for b in range (0,max_map_size):
  5599. tilemap[a].append(0)
  5600. m = maP(name,tilemap)
  5601. m.map_type = 'overworld'
  5602. m.set_music('overworld','night',True)
  5603. screen.render_load(3,2)
  5604. m.fill(tl.tlist['local'][0])#fill the map with grass
  5605. # set scrubs
  5606. for y in range (0,max_map_size):
  5607. for x in range (0,max_map_size):
  5608. if helpmap.tilemap[y][x].techID == tl.tlist['help'][0].techID: #<---scrub here
  5609. chance = random.randint(0,99)
  5610. if chance < chance_scrubs:
  5611. scrubs = (1,3,4,6,7,8,9)
  5612. coin = random.randint(0,len(scrubs)-1)
  5613. m.tilemap[y][x] = deepcopy(tl.tlist['local'][scrubs[coin]])
  5614. m.tilemap[y][x].replace = tl.tlist['local'][0]
  5615. screen.render_load(3,3)
  5616. #set trees
  5617. for y in range (0,max_map_size):
  5618. for x in range (0,max_map_size):
  5619. if helpmap.tilemap[y][x].techID == tl.tlist['help'][1].techID: #<---tree here
  5620. chance = random.randint(0,99)
  5621. if chance < chance_trees:
  5622. coin = random.randint(10,13)
  5623. m.tilemap[y][x] = tl.tlist['local'][coin]
  5624. m.tilemap[y][x].replace = tl.tlist['local'][0]#grass
  5625. screen.render_load(3,4)
  5626. #set herbs
  5627. for y in range (0,max_map_size):
  5628. for x in range (0,max_map_size):
  5629. if helpmap.tilemap[y][x].techID == tl.tlist['help'][0].techID: #<---scrub here
  5630. chance = random.randint(0,99)
  5631. if chance < chance_herbs:
  5632. coin = random.randint(15,16)
  5633. m.tilemap[y][x] = tl.tlist['local'][coin]
  5634. m.tilemap[y][x].replace = tl.tlist['local'][0]#grass
  5635. screen.render_load(3,5)
  5636. # set rocks
  5637. for n in range (0,number_rocks):
  5638. x = random.randint(0,max_map_size-1)
  5639. y = random.randint(0,max_map_size-1)
  5640. m.tilemap[y][x] = tl.tlist['local'][14]
  5641. m.tilemap[y][x].replace = tl.tlist['local'][0]#grass
  5642. screen.render_load(3,6)
  5643. #set water
  5644. for y in range (0,max_map_size):
  5645. for x in range (0,max_map_size):
  5646. if helpmap.tilemap[y][x].techID == tl.tlist['help'][2].techID: #<---water here
  5647. m.tilemap[y][x] = tl.tlist['misc'][0] # set low water here
  5648. screen.render_load(3,7)
  5649. m.exchange_when_surrounded(tl.tlist['misc'][0],tl.tlist['misc'][3],8) # exchange low wather against deep water
  5650. pos = (int(max_map_size/2),int(max_map_size/2))
  5651. #set portal
  5652. m.tilemap[pos[1]][pos[0]-5] = deepcopy(tl.tlist['portal'][8])
  5653. m.tilemap[pos[1]][pos[0]-5].replace = tl.tlist['local'][0]
  5654. #set stair down
  5655. m.tilemap[pos[1]+1][pos[0]] = deepcopy(tl.tlist['functional'][1])
  5656. m.set_frame(tl.tlist['functional'][0])
  5657. screen.render_load(3,8)
  5658. #set dungeon
  5659. ran_pos = m.find_any(tl.tlist['local'][0])
  5660. m.tilemap[ran_pos[1]][ran_pos[0]] = deepcopy(tl.tlist['dungeon'][7])
  5661. for q in range(0,int(max_map_size**2/50**2)*3):
  5662. m.make_orc_cave(tl.tlist['local'][0])#generate orc caves on grass
  5663. for v in range(0,10):
  5664. pos = m.find_any(tl.tlist['local'][0])
  5665. m.npcs[pos[1]][pos[0]] = ml.mlist['statue'][0]
  5666. m.npcs[pos[1]][pos[0]].lp = 999
  5667. m.npcs[pos[1]][pos[0]].basic_attribute.max_lp = 999
  5668. m.spawn_monsters(0)
  5669. self.maplist[0][name] = m
  5670. screen.render_load(3,9)
  5671. return pos
  5672. def shop_generator(self,style):
  5673. #0: Basic initializing
  5674. screen.render_load(19,0)
  5675. name = 'shop_0_0'
  5676. tilemap = []
  5677. for a in range (0,max_map_size):
  5678. tilemap.append([])
  5679. for b in range (0,max_map_size):
  5680. tilemap[a].append(0)
  5681. m = maP(name,tilemap)
  5682. m.map_type = style
  5683. m.build_type = 'None'
  5684. m.monster_plus = 0
  5685. m.monster_num = 0
  5686. m.set_music('shop','shop',True)
  5687. m.fill(tl.tlist['functional'][0])
  5688. screen.render_load(19,10)
  5689. center_x = int(max_map_size/2)
  5690. center_y = int(max_map_size/2)
  5691. for y in range(center_y-4,center_y+5):
  5692. for x in range(center_x-4,center_x+5):
  5693. m.tilemap[y][x] = deepcopy(tl.tlist['shop'][1])#wall
  5694. screen.render_load(19,20)
  5695. for y in range(center_y-3,center_y+4):
  5696. for x in range(center_x-3,center_x+4):
  5697. m.tilemap[y][x] = deepcopy(tl.tlist['dungeon'][1])#corridor
  5698. screen.render_load(19,30)
  5699. for y in range(center_y-2,center_y+3):
  5700. for x in range(center_x-2,center_x+3):
  5701. m.tilemap[y][x] = deepcopy(tl.tlist['shop'][1])#shop wall
  5702. screen.render_load(19,50)
  5703. for y in range(center_y-1,center_y+2):
  5704. for x in range(center_x-1,center_x+2):
  5705. m.tilemap[y][x] = deepcopy(tl.tlist['shop'][0])#shop floor
  5706. screen.render_load(19,70)
  5707. m.tilemap[center_y-2][center_x] = deepcopy(tl.tlist['shop'][2])#shop door
  5708. m.tilemap[center_y-3][center_x-1] = deepcopy(tl.tlist['shop'][5])#sign
  5709. m.tilemap[center_y-3][center_x-1].replace = deepcopy(tl.tlist['dungeon'][1])
  5710. m.tilemap[center_y-3][center_x].techID = -9999#nothing shall spawn here
  5711. m.tilemap[center_y-4][center_x] = deepcopy(tl.tlist['shop'][3])#shop exit
  5712. if style == 'pharmacy':
  5713. m.tilemap[center_y-3][center_x-1].move_mes = '[Naeria\'s Pharmacy]'
  5714. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][3])
  5715. elif style == 'pickaxe':
  5716. m.tilemap[center_y-3][center_x-1].move_mes = '[Eklor\'s Pickaxe Empire]'
  5717. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][4])
  5718. elif style == 'hardware':
  5719. m.tilemap[center_y-3][center_x-1].move_mes = '[Grimork\'s Hardware Store]'
  5720. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][5])
  5721. elif style == 'deco':
  5722. m.tilemap[center_y-3][center_x-1].move_mes = '[Larosa\'s Decoration Store]'
  5723. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][6])
  5724. elif style == 'book':
  5725. m.tilemap[center_y-3][center_x-1].move_mes = '[Xirazzzia\'s Bookshelf]'
  5726. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][7])
  5727. elif style == 'bomb':
  5728. m.tilemap[center_y-3][center_x-1].move_mes = '[Torguly\'s eXplozives Of al kinD]'
  5729. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][8])
  5730. elif style == 'general':
  5731. m.tilemap[center_y-3][center_x-1].move_mes = '[Arialu\'s General Store]'
  5732. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][9])
  5733. screen.render_load(19,90)
  5734. coin = random.randint(0,1)
  5735. if coin == 1:
  5736. pos = m.find_any(tl.tlist['dungeon'][1])
  5737. coin2 = random.randint(0,3)
  5738. if coin2 == 0:
  5739. replace = m.tilemap[pos[1]][pos[0]]
  5740. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['misc'][9])
  5741. m.tilemap[pos[1]][pos[0]].replace = replace
  5742. elif coin2 == 1:
  5743. replace = m.tilemap[pos[1]][pos[0]]
  5744. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['misc'][11])
  5745. m.tilemap[pos[1]][pos[0]].replace = replace
  5746. elif coin2 == 2:
  5747. m.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['cave'][2])
  5748. m.set_monster_strength(pos[0],pos[1],1)
  5749. else:
  5750. m.make_special_monsters(1,2,tl.tlist['dungeon'][1],1,'vase')
  5751. self.maplist[1][name] = m
  5752. screen.render_load(19,99)
  5753. def dungeon_generator(self,monster_plus,stair_down=True,num_traps=10,style='Dungeon'):#possible other style = 'Tomb'
  5754. #0: Basic initializing
  5755. screen.render_load(19,0)#Render progress bar 0%
  5756. if player.pet_pos != False and player.pet_on_map != False:
  5757. pet_help = deepcopy(world.maplist[player.pet_pos[2]][player.pet_on_map].npcs[player.pet_pos[1]][player.pet_pos[0]])
  5758. world.maplist[player.pet_pos[2]][player.pet_on_map].npcs[player.pet_pos[1]][player.pet_pos[0]] = 0
  5759. player.pet_pos = [0,0,1]
  5760. player.pet_on_map = 'dungeon_0_0'
  5761. if style == 'Tomb': #Set the graphics
  5762. tl.tlist['dungeon'][1].tile_pos = (4,6) #
  5763. tl.tlist['dungeon'][6].tile_pos = (4,7) #Sandstone walls,hidden doors and corridors for the acient tomb
  5764. tl.tlist['dungeon'][9].tile_pos = (4,7) #
  5765. else: #
  5766. tl.tlist['dungeon'][1].tile_pos = (10,6) #
  5767. tl.tlist['dungeon'][6].tile_pos = (2,6) #Default walls,hidden doors and corridors for the default dungeon
  5768. tl.tlist['dungeon'][9].tile_pos = (2,6) #
  5769. name = 'dungeon_0_0'#map name
  5770. tilemap = [] #Initializing a empty tilemap
  5771. for a in range (0,max_map_size): #
  5772. tilemap.append([]) #
  5773. for b in range (0,max_map_size): #
  5774. tilemap[a].append(0) #
  5775. m = maP(name,tilemap) #Generate a Map-object
  5776. if style == 'Tomb': #
  5777. m.map_type = 'tomb' #
  5778. m.set_music('tomb','tomb',True) #
  5779. else: #
  5780. m.map_type = 'dungeon' #and set a few constants for the new map
  5781. m.set_music('dungeon','dungeon',True)#
  5782. m.build_type = 'None' #
  5783. m.monster_plus = monster_plus #
  5784. m.monster_num = 0.3 #
  5785. m.no_monster_respawn = True #
  5786. m.fill(tl.tlist['dungeon'][9])#fill the map with dungeon wall tiles
  5787. screen.render_load(19,10)#Render progress bar 10%
  5788. #1: Set rooms
  5789. #Important fact: No matter how big the mapsize is set,
  5790. #dundeons only use the 52x52 tiles in the upper left connor.
  5791. #Thats as big as a small map.
  5792. test_build = True #Seperate the dungeon in a 3x3 grit.
  5793. while test_build: #Every part of the grit has a 66% chance to be a room
  5794. parts_with_rooms = [] #
  5795. #
  5796. for part_y in range(0,3): #
  5797. for part_x in range(0,3): #
  5798. ran = random.randint(0,9) #
  5799. if ran > 3: #
  5800. pick = (part_x,part_y) #
  5801. parts_with_rooms.append(pick) #
  5802. if len(parts_with_rooms) > 5: #every dungeon level needs at least 5 rooms
  5803. test_build = False #
  5804. coord_x = [] #transform the coordinates from the 3x3 grit into
  5805. coord_y = [] #real coordinates on the tilemap(center of the rooms)
  5806. #
  5807. for c in parts_with_rooms: #
  5808. x_offset = random.randint(0,5) #
  5809. y_offset = random.randint(0,5) #
  5810. #
  5811. real_x = 9+(15*c[0])+x_offset #
  5812. real_y = 9+(15*c[1])+y_offset #
  5813. #
  5814. coord_x.append(real_x) #
  5815. coord_y.append(real_y) #
  5816. m.imp_connect(coord_x,coord_y,tl.tlist['dungeon'][1],tl.tlist['dungeon'][0],tl.tlist['dungeon'][0])#connect the room cooardinathe with corridor
  5817. for i in range(0,len(coord_x)-1):#set variable roome size for all rooms
  5818. x_minus = random.randint(2,4)#
  5819. x_plus = random.randint(3,5) #
  5820. y_minus = random.randint(2,4)#
  5821. y_plus = random.randint(3,5) #
  5822. for yy in range(coord_y[i]-y_minus-1,coord_y[i]+y_plus+1): #draw walls around the rooms
  5823. for xx in range(coord_x[i]-x_minus-1,coord_x[i]+x_plus+1): #
  5824. m.tilemap[yy][xx] = deepcopy(tl.tlist['dungeon'][9]) #
  5825. for yy in range(coord_y[i]-y_minus,coord_y[i]+y_plus): #draw the room floor
  5826. for xx in range(coord_x[i]-x_minus,coord_x[i]+x_plus): #
  5827. m.tilemap[yy][xx] = tl.tlist['dungeon'][0] #
  5828. screen.render_load(19,25) #progress bar 25%
  5829. #2: Set doors
  5830. for yyy in range(0,52):
  5831. for xxx in range(0,52): #the 52 is hard scripted to safe performance
  5832. if m.tilemap[yyy][xxx].techID == tl.tlist['dungeon'][9].techID: #Set all tiles that are surrounded by two moveable tiles on two opponent sides as doors
  5833. if m.tilemap[yyy-1][xxx].move_group == 'soil' and m.tilemap[yyy+1][xxx].move_group == 'soil': #
  5834. m.tilemap[yyy][xxx] = tl.tlist['dungeon'][3] #
  5835. elif m.tilemap[yyy][xxx-1].move_group == 'soil' and m.tilemap[yyy][xxx+1].move_group == 'soil': #
  5836. m.tilemap[yyy][xxx] = tl.tlist['dungeon'][3] #
  5837. for yyy in range(0,52):
  5838. for xxx in range(0,52): #the 52 is hard scripted to safe performance
  5839. if m.tilemap[yyy][xxx].techID == tl.tlist['dungeon'][3].techID: #Remove all doors that are next to another door.
  5840. size = m.get_quarter_size(xxx,yyy) #Only spare one door per wall
  5841. if size[0] > 1: #
  5842. for rx in range(xxx,xxx+size[0]+1): #
  5843. m.tilemap[yyy][rx] = deepcopy(tl.tlist['dungeon'][9]) #
  5844. rrx = int(xxx+((rx-xxx)/2)) #
  5845. m.tilemap[yyy][rrx] = tl.tlist['dungeon'][3] #
  5846. #
  5847. if m.tilemap[yyy-1][rrx].move_group != 'soil': #
  5848. m.tilemap[yyy-1][rrx] = tl.tlist['dungeon'][1] #
  5849. if m.tilemap[yyy+1][rrx].move_group != 'soil': #
  5850. m.tilemap[yyy+1][rrx] = tl.tlist['dungeon'][1] #
  5851. #
  5852. if size[1] > 1: #
  5853. for ry in range(yyy,yyy+size[1]+1): #
  5854. m.tilemap[ry][xxx] = deepcopy(tl.tlist['dungeon'][9]) #
  5855. rry = int(yyy+((ry-yyy)/2)) #
  5856. m.tilemap[rry][xxx] = tl.tlist['dungeon'][3] #
  5857. #
  5858. if m.tilemap[rry][xxx-1].move_group != 'soil': #
  5859. m.tilemap[rry][xxx-1] = tl.tlist['dungeon'][1] #
  5860. if m.tilemap[rry][xxx+1].move_group != 'soil': #
  5861. m.tilemap[rry][xxx+1] = tl.tlist['dungeon'][1] #
  5862. screen.render_load(19,40)#Render progress bar 40%
  5863. test = deepcopy(m) #Make a copy of the map as is
  5864. pos = test.find_first(tl.tlist['dungeon'][0]) #and performe a float test,
  5865. test.floating(pos[0],pos[1],tl.tlist['misc'][0],tl.tlist['dungeon'][9]) #in order to find not conected parts.
  5866. screen.render_load(19,50) #Render progress bar 50%
  5867. for yyy in range(0,52): #Remove not connected parts
  5868. for xxx in range(0,52): #
  5869. if test.tilemap[yyy][xxx].techID != tl.tlist['dungeon'][9].techID and test.tilemap[yyy][xxx].techID != tl.tlist['misc'][0].techID: #
  5870. m.tilemap[yyy][xxx] = tl.tlist['dungeon'][9] #
  5871. screen.render_load(19,60)#Render progress bar 60%
  5872. for yyy in range(0,52): #Randomize doors:
  5873. for xxx in range(0,52): #-normal door
  5874. #-resisting door
  5875. if m.tilemap[yyy][xxx].techID == tl.tlist['dungeon'][3].techID: #-etc.
  5876. ran = random.randint(3,6) #
  5877. m.tilemap[yyy][xxx] = tl.tlist['dungeon'][ran] #
  5878. if m.tilemap[yyy][xxx].techID == tl.tlist['dungeon'][9].techID: #Randomize wall design
  5879. ran_test = random.randint(0,99) #
  5880. if ran_test > 75: #
  5881. if style == 'Dungeon': #
  5882. ran = random.randint(0,2) #
  5883. m.tilemap[yyy][xxx].tile_pos = (11,0+ran) #
  5884. if style == 'Tomb': #
  5885. ran = random.randint(0,2) #
  5886. m.tilemap[yyy][xxx].tile_pos = (12,0+ran) #
  5887. screen.render_load(19,70)#Render progress bar 70%
  5888. #3: Make stairs
  5889. stair_up_pos = m.find_any(tl.tlist['dungeon'][0]) #Set a up leading stair on any floor tile.
  5890. entrance_x = stair_up_pos[0] #
  5891. entrance_y = stair_up_pos[1] #
  5892. if style == 'Tomb': #
  5893. m.tilemap[stair_up_pos[1]][stair_up_pos[0]] = tl.tlist['dungeon'][19] #
  5894. else: #
  5895. m.tilemap[stair_up_pos[1]][stair_up_pos[0]] = tl.tlist['dungeon'][8] #
  5896. for sy in range(stair_up_pos[1]-4,stair_up_pos[1]+5):
  5897. for sx in range(stair_up_pos[0]-4,stair_up_pos[0]+5):
  5898. try:
  5899. if m.tilemap[sy][sx].move_group == 'soil':
  5900. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  5901. m.tilemap[sy][sx].move_group = 'dry_entrance'
  5902. elif m.tilemap[sy][sx].move_group == 'low_liquid':
  5903. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  5904. m.tilemap[sy][sx].move_group = 'wet_entrance'
  5905. except:
  5906. None
  5907. if style == 'Tomb':
  5908. if monster_plus == 10:
  5909. pos = m.find_any(tl.tlist['dungeon'][0])
  5910. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['dungeon'][16])
  5911. else:
  5912. if monster_plus == 1 and not 'gilmenor_rescued' in player.quest_variables: #set gilmenor
  5913. pos = m.find_any(tl.tlist['dungeon'][0]) #
  5914. m.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['cage'][0]) #
  5915. m.set_monster_strength(pos[0],pos[1],1,lvl_bonus=9) #
  5916. pos2 = m.find_any(tl.tlist['dungeon'][0]) #
  5917. m.tilemap[pos2[1]][pos2[0]] = deepcopy(tl.tlist['portal'][9]) #
  5918. m.tilemap[pos2[1]][pos2[0]].replace = deepcopy(tl.tlist['dungeon'][0])
  5919. if monster_plus == 3:
  5920. pos = m.find_any(tl.tlist['dungeon'][0])
  5921. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['dungeon'][14])
  5922. if stair_down == True: #If we are not on the deepest lvl:
  5923. stair_down_pos = m.find_any(tl.tlist['dungeon'][0]) #Set a down leading stair on any floor tile.
  5924. if style == 'Tomb': #
  5925. m.tilemap[stair_down_pos[1]][stair_down_pos[0]] = tl.tlist['dungeon'][18] #
  5926. else: #
  5927. m.tilemap[stair_down_pos[1]][stair_down_pos[0]] = tl.tlist['dungeon'][7] #
  5928. else: #Make a chest whit a reward on the deepest lvl instead
  5929. chest_pos = m.find_any(tl.tlist['dungeon'][0]) #
  5930. m.tilemap[chest_pos[1]][chest_pos[0]] = tl.tlist['dungeon'][20] #
  5931. m.tilemap[chest_pos[1]][chest_pos[0]].replace = tl.tlist['dungeon'][0] #
  5932. if style == 'Tomb':
  5933. m.add_container([il.ilist['special_clothe'][0],il.ilist['misc'][33],il.ilist['misc'][40]],chest_pos[0],chest_pos[1])# set the interior of the chest
  5934. else: #
  5935. m.add_container([il.ilist['special_clothe'][1],il.ilist['misc'][33],il.ilist['misc'][41]],chest_pos[0],chest_pos[1])#
  5936. egg_pos = stair_up_pos = m.find_any(tl.tlist['dungeon'][0]) #set monster egg
  5937. m.tilemap[egg_pos[1]][egg_pos[0]] = tl.tlist['functional'][34] #
  5938. m.tilemap[egg_pos[1]][egg_pos[0]].replace = tl.tlist['dungeon'][0] #
  5939. screen.render_load(19,80)#Render progress bar 80%
  5940. #4: Make Traps
  5941. for i in range(0,num_traps): #Set hidden traps on random floor tiles.
  5942. pos = m.find_any(tl.tlist['dungeon'][0]) #
  5943. replace = m.tilemap[pos[1]][pos[0]] #
  5944. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['dungeon'][10]) #Traps have to be deepcopied to work proper.
  5945. m.tilemap[pos[1]][pos[0]].replace = replace #
  5946. screen.render_load(19,90) #Render Progress bar 90%
  5947. #5: Make interior
  5948. num_rooms = len(parts_with_rooms) #Make chests with random loot
  5949. m.make_containers(int(num_rooms/3),int(num_rooms/2),tl.tlist['dungeon'][0],1,3,'chest') #
  5950. for c in range(0,num_rooms): #Set random fontains on floor tiles
  5951. pos = m.find_any(tl.tlist['dungeon'][0]) #
  5952. ran = random.randint(0,99) #
  5953. if ran < 15: #
  5954. tile = deepcopy(tl.tlist['dungeon'][12]) #acid fontain
  5955. elif ran > 84: #
  5956. tile = deepcopy(tl.tlist['dungeon'][13]) #healing fontain
  5957. else: #
  5958. tile = deepcopy(tl.tlist['functional'][7]) #fontain
  5959. tile.civilisation = False #
  5960. tile.build_here = False #
  5961. tile.can_grown = False #
  5962. tile.replace = tl.tlist['dungeon'][0] #
  5963. m.tilemap[pos[1]][pos[0]] = tile #
  5964. coin = random.randint(0,1) #Set a Altar on 50% of all maps
  5965. if coin == 1: #that are generated with this function
  5966. pos = m.find_any(tl.tlist['dungeon'][0]) #
  5967. tile = deepcopy(tl.tlist['functional'][15]) #
  5968. tile.civilisation = False #
  5969. tile.build_here = False #
  5970. tile.can_grown = False #
  5971. tile.replace = tl.tlist['dungeon'][0] #
  5972. m.tilemap[pos[1]][pos[0]] = tile #
  5973. #num_statue = random.randint(4,6) #generate random statues
  5974. #for l in range(0,num_statue): #
  5975. # kind = random.randint(0,len(tl.tlist['statue'])-1) #
  5976. # pos = m.find_any(tl.tlist['dungeon'][0]) #
  5977. # tile = deepcopy(tl.tlist['statue'][kind]) #
  5978. # tile.replace = tl.tlist['dungeon'][0] #
  5979. # m.tilemap[pos[1]][pos[0]] = tile #
  5980. num_deco = random.randint(8,10) #generate random deco
  5981. for l in range(0,num_deco): #
  5982. if style == 'Tomb': #
  5983. kind = random.randint(3,5) #
  5984. else: #
  5985. kind = random.randint(0,2) #
  5986. pos = m.find_any(tl.tlist['dungeon'][0]) #
  5987. tile = deepcopy(tl.tlist['deco'][kind]) #
  5988. tile.replace = tl.tlist['dungeon'][0] #
  5989. m.tilemap[pos[1]][pos[0]] = tile #
  5990. #coin_cage = random.randint(0,2) #spawn cages
  5991. #if coin_cage == 1: #
  5992. # pos = m.find_any(tl.tlist['dungeon'][0]) #
  5993. # m.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['cage'][random.randint(0,len(ml.mlist['cage'])-1)]) #
  5994. # m.set_monster_strength(pos[0],pos[1],1,lvl_bonus=9) #
  5995. # pos2 = m.find_any(tl.tlist['dungeon'][0]) #
  5996. # m.tilemap[pos2[1]][pos2[0]] = deepcopy(tl.tlist['portal'][9]) #
  5997. # m.tilemap[pos2[1]][pos2[0]].replace = deepcopy(tl.tlist['dungeon'][0]) #
  5998. ran_statue = random.randint(0,99) #make animated statues
  5999. num_statue = 0 #
  6000. if ran_statue > 49 and ran_statue < 70: #
  6001. num_statue = 2 #
  6002. elif ran_statue < 90: #
  6003. num_statue = 3 #
  6004. elif ran_statue > 89: #
  6005. num_statue = 4 #
  6006. #
  6007. if num_statue > 0: #
  6008. m.make_special_monsters(1,num_statue,tl.tlist['dungeon'][0],m.monster_plus,'animated statue') #
  6009. m.spawn_monsters(0) #Spawn initial monsters
  6010. m.make_special_monsters(10,20,tl.tlist['dungeon'][0],m.monster_plus,'vase') #
  6011. m.make_special_monsters(1,2,tl.tlist['dungeon'][0],m.monster_plus,'mimic') #
  6012. if style == 'Tomb': #
  6013. m.make_special_monsters(1,3,tl.tlist['dungeon'][0],m.monster_plus,'demonic chest') #
  6014. coin = random.randint(0,1)
  6015. if coin == 1:
  6016. m.spawn_magic_shops()
  6017. if player.pet_pos != False and player.pet_on_map != False:
  6018. m.npcs[0][0] = pet_help
  6019. self.maplist[1][name] = m # Add map to world.maplist
  6020. screen.render_load(19,99) #Render progress bar 99%
  6021. def desert_generator(self,chance_object):
  6022. #chance_objects must be between 0 and 99
  6023. screen.render_load(18,1)
  6024. name = 'desert_0_0'
  6025. tilemap = []
  6026. for a in range (0,max_map_size):
  6027. tilemap.append([])
  6028. for b in range (0,max_map_size):
  6029. tilemap[a].append(0)
  6030. m = maP(name,tilemap)
  6031. m.map_type = 'desert'
  6032. m.build_type = 'Full'
  6033. m.monster_plus = 7
  6034. m.thirst_multi_day = 2
  6035. m.set_music('desert','night',True)
  6036. m.fill(tl.tlist['extra'][0])
  6037. y_river = random.randint((17),(max_map_size-17))
  6038. river_offset = random.randint(-3,3)
  6039. plus = 0
  6040. minus = 0
  6041. screen.render_load(18,20)
  6042. for c in range (0,max_map_size):
  6043. for g in range (-2,7):
  6044. m.tilemap[y_river+river_offset+g][c] = tl.tlist['local'][0]#set grass
  6045. for w in range (0,5):
  6046. m.tilemap[y_river+river_offset+w][c] = tl.tlist['misc'][0]#set low water
  6047. if river_offset < 4:
  6048. plus = 1
  6049. else:
  6050. plus = 0
  6051. if river_offset > -4:
  6052. minus = -1
  6053. else:
  6054. minus = 0
  6055. offset_change = random.randint(minus,plus)
  6056. river_offset += offset_change
  6057. m.exchange_when_surrounded(tl.tlist['misc'][0],tl.tlist['misc'][3],7)
  6058. screen.render_load(18,40)
  6059. for b in range(2,max_map_size-2,10):
  6060. #north side of the river
  6061. building_offset =random.randint(0,4)
  6062. number_beds = 0
  6063. for y in range(y_river-12,y_river-7):
  6064. for x in range(b+building_offset,b+building_offset+5):
  6065. if x == b+building_offset or x == b+building_offset+4:
  6066. if y == y_river-10:
  6067. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][9])
  6068. else:
  6069. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][2])
  6070. elif y == y_river-12 or y == y_river-8:
  6071. if x == b+building_offset+2:
  6072. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][9])
  6073. else:
  6074. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][2])
  6075. else:
  6076. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][1])
  6077. if x == b+building_offset+1 or x == b+building_offset+3:
  6078. if y == y_river-11 or y == y_river-9:
  6079. obj_here = random.randint(0,2) #0: nothing, 1:bed 2:workbench
  6080. if number_beds == 0:
  6081. obj_here = 1
  6082. if obj_here != 0:
  6083. if obj_here == 1:
  6084. obj = ('functional',8)
  6085. number_beds += 1
  6086. else:
  6087. ran = random.randint(9,15)
  6088. obj = ('functional',ran)
  6089. m.tilemap[y][x] = deepcopy(tl.tlist[obj[0]][obj[1]])
  6090. m.tilemap[y][x].replace = deepcopy(tl.tlist['extra'][1])
  6091. m.tilemap[y][x].civilisation = False
  6092. m.tilemap[y][x].build_here = False
  6093. m.tilemap[y][x].move_group = 'house'
  6094. #south side of the river
  6095. building_offset = random.randint(0,4)
  6096. number_beds = 0
  6097. screen.render_load(18,60)
  6098. for y in range(y_river+8,y_river+13):
  6099. for x in range(b+building_offset,b+building_offset+5):
  6100. if x == b+building_offset or x == b+building_offset+4:
  6101. if y == y_river+10:
  6102. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][9])
  6103. else:
  6104. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][2])
  6105. elif y == y_river+12 or y == y_river+8:
  6106. if x == b+building_offset+2:
  6107. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][9])
  6108. else:
  6109. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][2])
  6110. else:
  6111. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][1])
  6112. if x == b+building_offset+1 or x == b+building_offset+3:
  6113. if y == y_river+9 or y == y_river+11:
  6114. obj_here = random.randint(0,2) #0: nothing, 1:bed 2:workbench
  6115. if number_beds == 0:
  6116. obj_here = 1
  6117. if obj_here != 0:
  6118. if obj_here == 1:
  6119. obj = ('functional',8)
  6120. number_beds += 1
  6121. else:
  6122. ran = random.randint(9,15)
  6123. obj = ('functional',ran)
  6124. m.tilemap[y][x] = deepcopy(tl.tlist[obj[0]][obj[1]])
  6125. m.tilemap[y][x].replace = deepcopy(tl.tlist['extra'][1])
  6126. m.tilemap[y][x].civilisation = False
  6127. m.tilemap[y][x].build_here = False
  6128. m.tilemap[y][x].move_group = 'house'
  6129. make_bridges = True
  6130. num_bridges = 0
  6131. num_bridges_max = ((max_map_size/50)*3)+1
  6132. screen.render_load(18,80)
  6133. while num_bridges < num_bridges_max:
  6134. x_pos = random.randint(5,max_map_size-5)
  6135. num_wall = 0
  6136. for test in range(0,max_map_size):
  6137. if m.tilemap[test][x_pos].techID == tl.tlist['extra'][2].techID:
  6138. num_wall += 1
  6139. if num_wall == 0:
  6140. num_bridges += 1
  6141. for y in range(0,max_map_size):
  6142. if m.tilemap[y][x_pos].techID == tl.tlist['misc'][0].techID or m.tilemap[y][x_pos].techID == tl.tlist['misc'][3].techID: #this is low wather or deep water
  6143. replace = deepcopy(m.tilemap[y][x_pos])
  6144. m.tilemap[y][x_pos] = deepcopy(tl.tlist['extra'][8])
  6145. m.tilemap[y][x_pos].replace = replace
  6146. for y in range (0,max_map_size):
  6147. for x in range (0,max_map_size):
  6148. if m.tilemap[y][x].techID == tl.tlist['extra'][0].techID:
  6149. chance = random.randint(0,99)
  6150. if chance < chance_object:
  6151. obj_numbers = (3,4,5,14)
  6152. coin = random.randint(0,len(obj_numbers)-1)
  6153. m.tilemap[y][x] = tl.tlist['extra'][obj_numbers[coin]]
  6154. m.tilemap[y][x].replace = tl.tlist['extra'][0]#sand
  6155. elif m.tilemap[y][x].techID == tl.tlist['local'][0].techID:
  6156. chance = random.randint(0,99)
  6157. if chance < chance_object:
  6158. coin = random.randint(10,13)
  6159. m.tilemap[y][x] = tl.tlist['extra'][coin]
  6160. m.tilemap[y][x].replace = tl.tlist['local'][0]#grass
  6161. elif m.tilemap[y][x].techID == tl.tlist['extra'][9].techID:
  6162. for yy in range(y-1,y+2):
  6163. if m.tilemap[yy][x].replace != None:
  6164. m.tilemap[yy][x] = m.tilemap[yy][x].replace
  6165. for xx in range(x-1,x+2):
  6166. if m.tilemap[y][xx].replace != None:
  6167. m.tilemap[y][xx] = m.tilemap[y][xx].replace
  6168. if m.tilemap[y][x].techID == tl.tlist['functional'][8].techID:#bed
  6169. ran = random.randint(5,6)
  6170. m.npcs[y][x] = deepcopy(ml.mlist['special'][ran])
  6171. m.set_monster_strength(x,y,0)
  6172. m.set_frame(tl.tlist['functional'][0])
  6173. screen.render_load(18,99)
  6174. #set portal
  6175. y = 2
  6176. x = random.randint(2,max_map_size-2)
  6177. m.tilemap[y][x] = tl.tlist['portal'][5]
  6178. m.tilemap[y][x].replace = tl.tlist['extra'][0]#sand
  6179. m.tilemap[y+1][x] = tl.tlist['extra'][0]#sand
  6180. #set tomb
  6181. ran_pos = m.find_any(tl.tlist['extra'][0])
  6182. m.tilemap[ran_pos[1]][ran_pos[0]] = tl.tlist['dungeon'][18]
  6183. m.spawn_monsters(0)
  6184. self.maplist[0][name] = m
  6185. class mob():
  6186. def __init__(self, name, on_map, attribute, pos =[40,40,0],glob_pos=[0,0],build='Manual'):
  6187. self.name = name
  6188. self.on_map = on_map
  6189. self.attribute = attribute
  6190. self.lp = attribute.max_lp
  6191. self.mp = attribute.max_mp
  6192. self.pos = pos
  6193. self.glob_pos = glob_pos
  6194. self.last_map = 'Foo'
  6195. self.cur_map = 'Bar'
  6196. self.cur_z = self.pos[2]
  6197. self.last_z = 'Baz'
  6198. def move(self, x=0, y=0):
  6199. mc = self.move_check(x,y)
  6200. try:
  6201. tile_move_group = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group
  6202. except:
  6203. tile_move_group = 'solid'
  6204. print('move ERROR')
  6205. player_move_groups = ['soil','low_liquid','shop','house','wet_entrance','dry_entrance']
  6206. swim_check = True
  6207. for i in ('Head','Body','Legs','Feet'):
  6208. if player.inventory.wearing[i] != player.inventory.nothing:
  6209. swim_check = False
  6210. if swim_check == True:
  6211. player_move_groups.append('swim')
  6212. if player.buffs.get_buff('hexed') < 1:
  6213. player_move_groups.append('holy')
  6214. if self.buffs.get_buff('immobilized') > 0:
  6215. player_move_groups = ['not_existent_group1','not_existent_group2']
  6216. move_check2 = False
  6217. for j in player_move_groups:
  6218. if j == tile_move_group:
  6219. move_check2 = True
  6220. if mc == True:
  6221. if x > 0 and move_check2 == True and self.pos[0] < max_map_size - 1:
  6222. if self.pet_pos != False and self.pet_on_map != False:
  6223. try:
  6224. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].lp = 999 #set pets lp to 999 to make them unbreakable
  6225. if player.pet_pos[0] != player.pos[0] or player.pet_pos[1] != player.pos[1]:
  6226. world.maplist[self.pos[2]][self.on_map].npcs[self.pos[1]][self.pos[0]] = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]]
  6227. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]] = 0
  6228. self.pet_pos = deepcopy(self.pos)
  6229. self.pet_on_map = deepcopy(self.on_map)
  6230. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].relation += 1
  6231. relation = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].relation
  6232. evolve = False
  6233. if relation == 1000 and 'pet0' in world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].properties:
  6234. evolve = True
  6235. elif relation == 4000 and 'pet1' in world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].properties:
  6236. evolve = True
  6237. if evolve == True:
  6238. #screen.write_hit_matrix(self.pet_pos[0],self.pet_pos[1],7)
  6239. anger_monster = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].anger_monster #leveling monsters use the same mechanic like angering monsters
  6240. mo_name = deepcopy(world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].name)
  6241. memory = deepcopy(world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].memory)
  6242. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]] = deepcopy(ml.mlist['pet'][anger_monster])
  6243. world.maplist[self.pet_pos[2]][self.pet_on_map].set_monster_strength(self.pet_pos[0],self.pet_pos[1],1)
  6244. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].lp = 999
  6245. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].relation = relation
  6246. player.pet_lp = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].basic_attribute.max_lp
  6247. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].memory = memory
  6248. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].AI_style = 'company'
  6249. message.add(mo_name + 'envolved into a ' + world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].name + '!')
  6250. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].name = mo_name
  6251. except:
  6252. message.add('[PET ERROR: Unfollow pet]')
  6253. player.pet_pos = False
  6254. player.pet_on_map = False
  6255. self.pos[0] += 1
  6256. if x < 0 and move_check2 == True and self.pos[0] > 0:
  6257. if self.pet_pos != False and self.pet_on_map != False:
  6258. try:
  6259. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].lp = 999 #set pets lp to 999 to make them unbreakable
  6260. world.maplist[self.pos[2]][self.on_map].npcs[self.pos[1]][self.pos[0]] = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]]
  6261. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]] = 0
  6262. self.pet_pos = deepcopy(self.pos)
  6263. self.pet_on_map = deepcopy(self.on_map)
  6264. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].relation += 1
  6265. relation = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].relation
  6266. evolve = False
  6267. if relation == 1000 and 'pet0' in world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].properties:
  6268. evolve = True
  6269. elif relation == 4000 and 'pet1' in world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].properties:
  6270. evolve = True
  6271. if evolve == True:
  6272. #screen.write_hit_matrix(self.pet_pos[0],self.pet_pos[1],7)
  6273. anger_monster = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].anger_monster #leveling monsters use the same mechanic like angering monsters
  6274. mo_name = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].name
  6275. memory = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].memory
  6276. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]] = deepcopy(ml.mlist['pet'][anger_monster])
  6277. world.maplist[self.pet_pos[2]][self.pet_on_map].set_monster_strength(self.pet_pos[0],self.pet_pos[1],1)
  6278. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].lp = 999
  6279. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].relation = relation
  6280. player.pet_lp = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].basic_attribute.max_lp
  6281. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].memory = memory
  6282. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].AI_style = 'company'
  6283. message.add(mo_name + 'envolved into a ' + world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].name + '!')
  6284. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].name = mo_name
  6285. except:
  6286. message.add('[PET ERROR: Unfollow pet]')
  6287. player.pet_pos = False
  6288. player.pet_on_map = False
  6289. self.pos[0] -= 1
  6290. if y > 0 and move_check2 == True and self.pos[1] < max_map_size - 1:
  6291. if self.pet_pos != False and self.pet_on_map != False:
  6292. try:
  6293. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].lp = 999 #set pets lp to 999 to make them unbreakable
  6294. world.maplist[self.pos[2]][self.on_map].npcs[self.pos[1]][self.pos[0]] = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]]
  6295. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]] = 0
  6296. self.pet_pos = deepcopy(self.pos)
  6297. self.pet_on_map = deepcopy(self.on_map)
  6298. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].relation += 1
  6299. relation = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].relation
  6300. evolve = False
  6301. if relation == 1000 and 'pet0' in world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].properties:
  6302. evolve = True
  6303. elif relation == 4000 and 'pet1' in world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].properties:
  6304. evolve = True
  6305. if evolve == True:
  6306. #screen.write_hit_matrix(self.pet_pos[0],self.pet_pos[1],7)
  6307. anger_monster = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].anger_monster #leveling monsters use the same mechanic like angering monsters
  6308. mo_name = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].name
  6309. memory = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].memory
  6310. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]] = deepcopy(ml.mlist['pet'][anger_monster])
  6311. world.maplist[self.pet_pos[2]][self.pet_on_map].set_monster_strength(self.pet_pos[0],self.pet_pos[1],1)
  6312. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].lp = 999
  6313. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].relation = relation
  6314. player.pet_lp = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].basic_attribute.max_lp
  6315. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].memory = memory
  6316. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].AI_style = 'company'
  6317. message.add(mo_name + 'envolved into a ' + world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].name + '!')
  6318. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].name = mo_name
  6319. except:
  6320. message.add('[PET ERROR: Unfollow pet]')
  6321. player.pet_pos = False
  6322. player.pet_on_map = False
  6323. self.pos[1] += 1
  6324. if y < 0 and move_check2 == True and self.pos[1] > 0:
  6325. if self.pet_pos != False and self.pet_on_map != False:
  6326. try:
  6327. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].lp = 999 #set pets lp to 999 to make them unbreakable
  6328. world.maplist[self.pos[2]][self.on_map].npcs[self.pos[1]][self.pos[0]] = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]]
  6329. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]] = 0
  6330. self.pet_pos = deepcopy(self.pos)
  6331. self.pet_on_map = deepcopy(self.on_map)
  6332. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].relation += 1
  6333. relation = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].relation
  6334. evolve = False
  6335. if relation == 1000 and 'pet0' in world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].properties:
  6336. evolve = True
  6337. elif relation == 4000 and 'pet1' in world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].properties:
  6338. evolve = True
  6339. if evolve == True:
  6340. #screen.write_hit_matrix(self.pet_pos[0],self.pet_pos[1],7)
  6341. anger_monster = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].anger_monster #leveling monsters use the same mechanic like angering monsters
  6342. mo_name = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].name
  6343. memory = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].memory
  6344. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]] = deepcopy(ml.mlist['pet'][anger_monster])
  6345. world.maplist[self.pet_pos[2]][self.pet_on_map].set_monster_strength(self.pet_pos[0],self.pet_pos[1],1)
  6346. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].lp = 999
  6347. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].relation = relation
  6348. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].memory = memory
  6349. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].AI_style = 'company'
  6350. player.pet_lp = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].basic_attribute.max_lp
  6351. message.add(mo_name + ' envolved into a ' + world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].name + '!')
  6352. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].name = mo_name
  6353. except:
  6354. message.add('[PET ERROR: Unfollow pet]')
  6355. player.pet_pos = False
  6356. player.pet_on_map = False
  6357. self.pos[1] -= 1
  6358. self.stand_check()
  6359. def move_check(self,x,y):
  6360. pickaxe_damage = True
  6361. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group == 'door' or world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].techID == tl.tlist['dungeon'][6].techID:
  6362. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].techID == tl.tlist['dungeon'][4].techID or world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].techID == tl.tlist['dungeon'][5].techID or world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].techID == tl.tlist['dungeon'][6].techID:
  6363. #this is a resisting door or a hidden door
  6364. sfx.play('locked')
  6365. else:
  6366. sfx.play('open')
  6367. message.add(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_mes)
  6368. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].replace
  6369. return False
  6370. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group == 'shop_enter':
  6371. sfx.play('open')
  6372. screen.render_fade(True,False)
  6373. shop_types = ('pharmacy','pickaxe','hardware','deco','book','bomb','general')
  6374. ran = random.randint(0,len(shop_types)-1)
  6375. world.shop_generator(shop_types[ran])
  6376. self.save_pos=(self.pos[0],self.pos[1],self.pos[2],self.on_map)
  6377. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].replace
  6378. shop_pos = world.maplist[1]['shop_0_0'].find_first(tl.tlist['shop'][3])
  6379. self.pos[0] = shop_pos[0]
  6380. self.pos[1] = shop_pos[1]+1
  6381. self.pos[2] = 1
  6382. self.on_map = 'shop_0_0'
  6383. player.stand_check()
  6384. screen.render_fade(False,True)
  6385. return False
  6386. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group == 'shop_exit':
  6387. sfx.play('open')
  6388. self.pos[0] = self.save_pos[0]
  6389. self.pos[1] = self.save_pos[1]
  6390. self.pos[2] = self.save_pos[2]
  6391. self.on_map = self.save_pos[3]
  6392. player.stand_check()
  6393. screen.render_fade(False,True)
  6394. return False
  6395. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group == 'holy' and player.buffs.get_buff('hexed') > 0:
  6396. message.add('You can\'t pass blessed ground while you are hexed!')
  6397. return False
  6398. try:
  6399. if world.maplist[self.pos[2]][self.on_map].npcs[self.pos[1]+y][self.pos[0]+x] != 0:
  6400. player.attack_monster(self.pos[0]+x,self.pos[1]+y)
  6401. return False
  6402. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].destroy != False: #for digging
  6403. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].techID == tl.tlist['misc'][28].techID:#this is obsidian
  6404. heated_stone = True
  6405. else:
  6406. heated_stone = False
  6407. if player.pos[2] > 3 and heated_stone == False:
  6408. brimstone = True
  6409. else:
  6410. brimstone = False
  6411. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].techID != tl.tlist['misc'][28].techID and world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].techID != tl.tlist['global_caves'][2].techID:
  6412. #this is not obsidian or soft soil
  6413. stone = True
  6414. else:
  6415. stone = False
  6416. if self.attribute.pickaxe_power + player.inventory.wearing['Pickaxe'].attribute.pickaxe_power >= world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].destroy:
  6417. if self == player:
  6418. message.add(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_mes)
  6419. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].techID != tl.tlist['building'][3].techID: #this isn't a door
  6420. sfx.play('break')
  6421. try:
  6422. if self.skill.mining == 'Adept':
  6423. mat_addition = 2
  6424. elif self.skill.mining == 'Master':
  6425. mat_addition = 5
  6426. else:
  6427. mat_addition = 0
  6428. material = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].conected_resources[0]
  6429. mat_num = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].conected_resources[1] + mat_addition
  6430. mes = player.inventory.materials.add(material,mat_num)
  6431. message.add(mes)
  6432. if player.skill.mining != 'Master':
  6433. player.skill.mining_progress += 1
  6434. if player.skill.mining_progress == 200 and player.skill.mining != 'Adept':
  6435. player.skill.raise_skill('mining')
  6436. message.add('Your mining skill reaches adept level!')
  6437. sfx.play('lvl_up')
  6438. if player.skill.mining_progress == 1000 and player.skill.mining != 'Master':
  6439. player.skill.raise_skill('mining')
  6440. message.add('Your mining skill reaches master level!')
  6441. sfx.play('lvl_up')
  6442. except:
  6443. None
  6444. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].techID == tl.tlist['building'][3].techID: #this is a closed door
  6445. world.maplist[self.pos[2]][self.on_map].countdowns.append(countdown('door', self.pos[0]+x, self.pos[1]+y,3))
  6446. sfx.play('open')
  6447. stone = False
  6448. heated_stone = False
  6449. brimstone = False
  6450. pickaxe_damage = False
  6451. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = deepcopy(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].replace)
  6452. if heated_stone == True:#drop heated stone
  6453. ran = random.randint(0,99)
  6454. if ran < 5:
  6455. replace = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x]
  6456. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = deepcopy(tl.tlist['functional'][28])
  6457. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].replace = replace
  6458. elif brimstone == True:#drop brimstone
  6459. ran = random.randint(0,99)
  6460. if ran < 5:
  6461. replace = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x]
  6462. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = deepcopy(tl.tlist['functional'][29])
  6463. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].replace = replace
  6464. elif stone == True:#drop stone
  6465. ran = random.randint(0,99)
  6466. if ran < 5:
  6467. replace = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x]
  6468. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = deepcopy(tl.tlist['functional'][30])
  6469. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].replace = replace
  6470. if player.inventory.wearing['Pickaxe'] != player.inventory.nothing and pickaxe_damage == True:
  6471. player.inventory.wearing['Pickaxe'].take_damage()
  6472. if player.inventory.wearing['Pickaxe'].state > 0:
  6473. player.inventory.wearing['Pickaxe'].set_name()
  6474. else:
  6475. message.add('Your tool breaks into pieces.')
  6476. player.inventory.wearing['Pickaxe'] = player.inventory.nothing
  6477. sfx.play('item_break')
  6478. else:
  6479. if self == player:
  6480. message.add('You are unable to destroy this with the tool in your hand.')
  6481. return False
  6482. else:
  6483. None
  6484. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group == 'tree':
  6485. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].techID == tl.tlist['local'][12].techID:#this is a ordenary tree
  6486. apple = True
  6487. else:
  6488. apple = False
  6489. if player.inventory.wearing['Axe'] != player.inventory.nothing: #if player has a axe in his hand
  6490. chop_success = True
  6491. player.inventory.wearing['Axe'].take_damage()
  6492. if player.inventory.wearing['Axe'].state > 0:
  6493. player.inventory.wearing['Axe'].set_name()
  6494. else:
  6495. message.add('Your axe breaks into pieces.')
  6496. player.inventory.wearing['Axe'] = player.inventory.nothing
  6497. sfx.play('item_break')
  6498. else:
  6499. message.add('That hurts!')
  6500. player.lp -= 1
  6501. sfx.play('hit')
  6502. if random.randint(0,9) != 0: #90% to fail chopping down the wood with bare hands
  6503. chop_success = False
  6504. else:
  6505. chop_success = True
  6506. if chop_success == True:
  6507. if self.skill.woodcutting == 'Adept':
  6508. mat_addition = 2
  6509. elif self.skill.woodcutting == 'Master':
  6510. mat_addition = 5
  6511. else:
  6512. mat_addition = 0
  6513. material = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].conected_resources[0]
  6514. mat_num = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].conected_resources[1] + mat_addition
  6515. mes = player.inventory.materials.add(material,mat_num)
  6516. message.add(mes)
  6517. sfx.play('chop')
  6518. if player.skill.woodcutting != 'Master':
  6519. player.skill.woodcutting_progress += 1
  6520. if player.skill.woodcutting_progress == 200 and player.skill.woodcutting != 'Adept':
  6521. player.skill.raise_skill('woodcutting')
  6522. message.add('Your woodcutting skill reaches adept level!')
  6523. sfx.play('lvl_up')
  6524. if player.skill.woodcutting_progress == 1000 and player.skill.woodcutting != 'Master':
  6525. player.skill.raise_skill('woodcutting')
  6526. message.add('Your woodcutting skill reaches master level!')
  6527. sfx.play('lvl_up')
  6528. world.maplist[self.pos[2]][self.on_map].make_monsters_angry(self.pos[0],self.pos[1],'tree')
  6529. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = deepcopy(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].replace) #let the tree disappear
  6530. if apple == True:
  6531. ran = random.randint(0,99)
  6532. if ran < 5:
  6533. ran2 = random.randint(0,99)
  6534. replace = deepcopy(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x])
  6535. if ran2 < 20:
  6536. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = deepcopy(tl.tlist['functional'][32])
  6537. else:
  6538. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = deepcopy(tl.tlist['functional'][31])
  6539. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].replace = replace
  6540. return False
  6541. if self.buffs.get_buff('immobilized') == 0:
  6542. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group == 'low_liquid' or world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group == 'swim' or world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group == 'wet_entrance':
  6543. sfx.play('walk_wet')
  6544. else:
  6545. sfx.play('walk_dry')
  6546. else:
  6547. sfx.play('immobilized')
  6548. return True
  6549. except:
  6550. None
  6551. def stand_check(self):
  6552. if self.on_map != 'shop_0_0':
  6553. if self.on_map != self.cur_map:
  6554. self.last_map = self.cur_map
  6555. self.cur_map = self.on_map
  6556. if self.pos[2] != self.cur_z:
  6557. self.last_z = self.cur_z
  6558. self.cur_z = self.pos[2]
  6559. world.maplist[self.pos[2]][self.on_map].special_check(self.pos[0],self.pos[1])
  6560. radius = 5
  6561. if player.pos[2] > 0:
  6562. radius = 2
  6563. elif player.pos[2] == 0:
  6564. if time.hour > 22 or time.hour < 4:
  6565. radius = 2
  6566. elif time.hour > 21 or time.hour < 5:
  6567. radius = 3
  6568. elif time.hour > 20 or time.hour < 6:
  6569. radius = 4
  6570. elif time.hour > 19 or time.hour < 7:
  6571. radius = 5
  6572. if player.buffs.get_buff('light') > 0 or player.buffs.get_buff('night vision') > 0:
  6573. radius = 5
  6574. if player.buffs.get_buff('blind') > 0:
  6575. radius = 1
  6576. message.add(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].move_mes,True)
  6577. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].damage > 0 and player.buffs.get_buff('fireresistance') == 0:
  6578. self.lp = self.lp - world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].damage
  6579. if self == player:
  6580. try:
  6581. message.add(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].damage_mes + ' (' + str(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].damage) + ' Damage)')
  6582. except:
  6583. None
  6584. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].damage > 0 and world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].special_group == 'hot':
  6585. sfx_flame = False
  6586. body_list = ('Head','Body','Legs','Feet','Hold(R)','Hold(L)','Neck','Hand','Pickaxe','Axe')
  6587. for i in body_list:
  6588. if player.inventory.wearing[i] != player.inventory.nothing and player.inventory.wearing[i].material == 'wooden':
  6589. ran = random.randint(0,9)
  6590. if ran < 4:
  6591. message.add('Your '+player.inventory.wearing[i].name+' burns to ashes!')
  6592. player.inventory.wearing[i] = player.inventory.nothing
  6593. sfx_flame = True
  6594. if sfx_flame == True:
  6595. sfx.play('flame')
  6596. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].damage < 0:
  6597. if self.lp < self.attribute.max_lp:
  6598. self.lp = self.lp - world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].damage
  6599. luck = player.attribute.luck + player.inventory.wearing['Neck'].attribute.luck
  6600. if player.buffs.get_buff('blessed') != 0:
  6601. luck += 2
  6602. for y in range(player.pos[1]-1,player.pos[1]+2):
  6603. for x in range(player.pos[0]-1,player.pos[0]+2):
  6604. if world.maplist[self.pos[2]][self.on_map].tilemap[y][x].techID == tl.tlist['dungeon'][6].techID:#this is a secret door
  6605. ran = random.randint(0,25)#check players luck
  6606. if ran < luck:
  6607. world.maplist[self.pos[2]][self.on_map].tilemap[y][x] = deepcopy(tl.tlist['dungeon'][3])
  6608. message.add('You notice a hidden door.')
  6609. screen.write_hit_matrix(player.pos[0],player.pos[1],14)
  6610. screen.write_hit_matrix(x,y,15)
  6611. sfx.play('found')
  6612. if world.maplist[self.pos[2]][self.on_map].tilemap[y][x].techID == tl.tlist['dungeon'][10].techID and world.maplist[self.pos[2]][self.on_map].tilemap[y][x].tile_pos == (10,10):#this is a trap which isn't already found
  6613. ran = random.randint(0,25)#check players luck
  6614. if ran < luck:
  6615. world.maplist[self.pos[2]][self.on_map].tilemap[y][x].tile_pos = (10,8)
  6616. message.add('You notice a trap.')
  6617. screen.write_hit_matrix(player.pos[0],player.pos[1],14)
  6618. screen.write_hit_matrix(x,y,15)
  6619. sfx.play('found')
  6620. if world.maplist[self.pos[2]][self.on_map].tilemap[y][x].techID == tl.tlist['dungeon'][12].techID and world.maplist[self.pos[2]][self.on_map].tilemap[y][x].tile_pos == (6,3,10,12):#this is a fontain that isn't already known
  6621. ran = random.randint(0,15)#check players luck
  6622. if ran < luck:
  6623. world.maplist[self.pos[2]][self.on_map].tilemap[y][x].tile_pos = (12,11,12,12)
  6624. world.maplist[self.pos[2]][self.on_map].tilemap[y][x].use_group = 'dont_drink'
  6625. message.add('You notice a strange smell.')
  6626. screen.write_hit_matrix(player.pos[0],player.pos[1],14)
  6627. screen.write_hit_matrix(x,y,15)
  6628. sfx.play('found')
  6629. if world.maplist[self.pos[2]][self.on_map].tilemap[y][x].techID == tl.tlist['dungeon'][13].techID and world.maplist[self.pos[2]][self.on_map].tilemap[y][x].tile_pos == (6,3,10,12):#this is a fontain that isn't already known
  6630. ran = random.randint(0,15)#check players luck
  6631. if ran < luck:
  6632. world.maplist[self.pos[2]][self.on_map].tilemap[y][x].tile_pos = (11,11,11,12)
  6633. message.add('You notice a strange sparkle.')
  6634. screen.write_hit_matrix(player.pos[0],player.pos[1],14)
  6635. screen.write_hit_matrix(x,y,15)
  6636. sfx.play('found')
  6637. for y in range (-r