main.py 466 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459
  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. force_small_worlds = False
  26. cheat_mode = False
  27. Time_ready = False
  28. entrance_x = 0
  29. entrance_y = 0
  30. basic_path = os.path.dirname(os.path.realpath('main.py')) #just get the execution path for resources
  31. for t in sys.argv:
  32. if t == '-m':
  33. p = os.path.expanduser(basic_path)
  34. lf = open('rba.desktop','w')
  35. lf.write('[Desktop Entry]\n')
  36. lf.write('Type=Application\n')
  37. lf.write('Name=RogueBox Adventures\n')
  38. lf.write('Comment=A RogueBox Game\n')
  39. lf.write('Exec=sh ' + p + os.sep + 'LIB' + os.sep + 'run.sh\n')
  40. lf.write('Icon=' + p + os.sep + 'icon_big.png\n')
  41. lf.write('Terminal=false\n')
  42. lf.write('Categories=Game;')
  43. lf.close()
  44. rf_path = p + os.sep + 'LIB' + os.sep + 'run.sh'
  45. rf = open(rf_path,'w')
  46. rf.write('#This file was generated automatically. Please don\'t change anything.\n')
  47. rf.write('cd ' + p + '\n')
  48. rf.write('python ' + p + os.sep + 'run.py')
  49. sys_com = 'chmod +x ' + p + os.sep + 'rba.desktop'
  50. os.system(sys_com)
  51. exit(0)
  52. if t == '-c':
  53. cheat_mode = True
  54. if t == '-g':
  55. gcwz_input = True
  56. if t == '-s':
  57. force_small_worlds = True
  58. if t == '-h':
  59. home_save = True
  60. lib_path = basic_path + os.sep + 'LIB'
  61. data_path = basic_path + os.sep + 'DATA'
  62. if home_save == False:
  63. save_path = basic_path + os.sep + 'SAVE' + os.sep + 'World0'
  64. else:
  65. save_path = os.path.expanduser('~') + os.sep + '.config' + os.sep + 'RogueBox-Adventures' + os.sep + 'SAVE' + os.sep + 'World0'
  66. path = save_path.replace(os.sep+'World0','')
  67. if os.path.exists(path) == False:
  68. for c in range(0,5):
  69. ph = path + os.sep + 'World' + str(c)
  70. os.makedirs(ph)
  71. del path
  72. playing = False
  73. sys.path.append(lib_path)
  74. max_map_size = 52
  75. monitor = [0,0]
  76. try:
  77. import cPickle as p
  78. except:
  79. import pickle as p
  80. try:
  81. p.DEFAULT_PROTOCOL=0
  82. except:
  83. p.HIGHEST_PROTOCOL=0
  84. import random
  85. if gcwz_input == True:
  86. from getch_gcwz import *
  87. else:
  88. from getch import *
  89. from tile import tile
  90. from attribute import attribute
  91. from item import *
  92. from countdown import *
  93. import pygame
  94. from gra_files import *
  95. from util import *
  96. from monster import monster
  97. from copy import deepcopy
  98. from buffs import buffs
  99. from itemlist import *
  100. from tilelist import *
  101. from monsterlist import *
  102. from text import texts
  103. from skill import *
  104. from version import *
  105. game_options = game_options(basic_path,home_save)
  106. if game_options.check_version == 1:
  107. ver_string = check_version()
  108. else:
  109. ver_string = ' '
  110. class g_screen():
  111. def __init__(self, mode = game_options.screenmode, show_logo = True):
  112. string = 'RogueBoxAdventures ' + version +' "'+version_name+'"'
  113. pygame.display.set_caption(string)
  114. icon = pygame.image.load('icon_small.png')
  115. pygame.display.set_icon(icon)
  116. global monitor
  117. self.fire_mode = 0 #0: normal, 1: fire
  118. self.win_mode = mode
  119. self.hit_matrix = []
  120. for y in range(0,12):
  121. self.hit_matrix.append([])
  122. for x in range(0,15):
  123. self.hit_matrix[y].append(0)
  124. pygame.init()
  125. display_info = pygame.display.Info()
  126. if monitor == [0,0]:
  127. monitor[0] = display_info.current_w
  128. monitor[1] = display_info.current_h
  129. self.displayx = monitor[0]
  130. self.displayy = monitor[1]
  131. #check if the screenmode is 16:9
  132. if float(self.displayx/self.displayy) < float(16/9):
  133. self.displayx = monitor[0]-monitor[0]%16
  134. elif float(self.displayx/self.displayy) > float(16/9):
  135. self.displayy = monitor[1]-monitor[1]%9
  136. winstyle = pygame.FULLSCREEN
  137. if cheat_mode == True and self.win_mode == 2:
  138. self.win_mode = 1 #disable fullscreen in cheat mode
  139. if self.win_mode == 2:
  140. self.screen = pygame.display.set_mode((self.displayx,self.displayy),winstyle)
  141. pygame.mouse.set_visible(game_options.mousepad)
  142. elif self.win_mode == 0 and low_res == False:
  143. self.screen = pygame.display.set_mode((640,360))
  144. self.displayx = 640
  145. self.displayy = 360
  146. elif self.win_mode == 1 and low_res == False:
  147. self.screen = pygame.display.set_mode((1280,720))
  148. self.displayx = 1280
  149. self.displayy = 720
  150. font_path = basic_path + os.sep + 'FONT' + os.sep + 'PressStart2P.ttf'
  151. self.font = pygame.font.Font(font_path,8)
  152. if low_res == True:
  153. str_ext = '_low_res'
  154. else:
  155. str_ext = ''
  156. if __name__ == '__main__':
  157. show_logo = False
  158. if show_logo == True:
  159. display_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep
  160. ran = random.randint(0,4)
  161. i_name = display_path + 'logo' + str(ran) + str_ext + '.png'
  162. i = pygame.image.load(i_name)
  163. i = pygame.transform.scale(i,(self.displayx,self.displayy))
  164. self.screen.blit(i,(0,0))
  165. pygame.display.flip()
  166. getch(640,360,mode=1)
  167. display_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep
  168. ran = random.randint(0,4)
  169. i_name = display_path + 'logo_gpl' + str_ext + '.png'
  170. i = pygame.image.load(i_name)
  171. i = pygame.transform.scale(i,(self.displayx,self.displayy))
  172. self.screen.blit(i,(0,0))
  173. pygame.display.flip()
  174. getch(640,360,mode=1)
  175. display_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep
  176. i_name = display_path + 'oga' + str_ext + '.png'
  177. i = pygame.image.load(i_name)
  178. i = pygame.transform.scale(i,(self.displayx,self.displayy))
  179. self.screen.blit(i,(0,0))
  180. pygame.display.flip()
  181. getch(640,360,mode=1)
  182. def render_fade(self,fadeout,fadein,menu='default'):
  183. if menu == 'inventory':
  184. bg = player.inventory.render(0,0,simulate=True)
  185. elif menu == 'screen':
  186. bg = screen.screen
  187. elif menu == 'loot':
  188. bg = world.maplist[player.pos[2]][player.on_map].containers[player.pos[1]][player.pos[0]].inventory(simulated=True)
  189. elif menu == 'brake':
  190. bg = screen.render_brake(simulate=True)
  191. elif menu == 'main':
  192. bg = screen.render_main_menu(simulate=True)
  193. else:
  194. bg = self.render(0,True)
  195. clock = pygame.time.Clock()
  196. if fadein:
  197. for i in range(255,0,-15):
  198. helpsur = pygame.Surface((self.displayx,self.displayy))
  199. helpsur.fill((48,48,48))
  200. helpsur.set_alpha(i)
  201. self.screen.blit(bg,(0,0))
  202. self.screen.blit(helpsur,(0,0))
  203. pygame.display.flip()
  204. clock.tick(510)
  205. if fadeout:
  206. for i in range(0,255,15):
  207. helpsur = pygame.Surface((self.displayx,self.displayy))
  208. helpsur.fill((48,48,48))
  209. helpsur.set_alpha(i)
  210. self.screen.blit(bg,(0,0))
  211. self.screen.blit(helpsur,(0,0))
  212. pygame.display.flip()
  213. clock.tick(510)
  214. def reset_hit_matrix(self):
  215. self.hit_matrix = []
  216. for y in range(0,12):
  217. self.hit_matrix.append([])
  218. for x in range(0,15):
  219. self.hit_matrix[y].append(0)
  220. def write_hit_matrix(self,x,y,style):
  221. #style: 0:nothing
  222. # 1:fire_path
  223. # 2:fire_path_monster
  224. # 3:miss
  225. # 4:hit
  226. # 5:critical
  227. # 6:heal
  228. # 7:teleport
  229. # 8:minus_gem
  230. # 9:plus_gem
  231. # 10:plus_fish
  232. # 11:plus_shoe
  233. # 12:monster_lvl_up
  234. # 13:monster_die
  235. # 14:attention
  236. # 15:found
  237. # 16:drop
  238. # 17:fear
  239. # 18:blood_minus
  240. # 19:blood_plus
  241. # 20:throw
  242. # 21:minus_item
  243. # 22:plus_item
  244. # 23:spellwave
  245. xx = x - player.pos[0] + 8
  246. yy = y - player.pos[1] + 6
  247. try:
  248. if xx >= 0 and yy >= 0:
  249. self.hit_matrix[yy][xx] = style
  250. except:
  251. None
  252. def render_hits(self):
  253. s = pygame.Surface((480,360))
  254. s.fill((255,0,255))
  255. start = 0
  256. for y in range(start,len(self.hit_matrix)):
  257. for x in range(start,len(self.hit_matrix[0])):
  258. if self.hit_matrix[y][x] == 1:
  259. s.blit(gra_files.gdic['display'][11],(((x-start)*32),(y-start)*32))
  260. elif self.hit_matrix[y][x] == 2:
  261. s.blit(gra_files.gdic['display'][12],(((x-start)*32),(y-start)*32))
  262. elif self.hit_matrix[y][x] == 3:
  263. s.blit(gra_files.gdic['display'][13],(((x-start)*32),(y-start)*32))
  264. elif self.hit_matrix[y][x] == 4:
  265. s.blit(gra_files.gdic['display'][14],(((x-start)*32),(y-start)*32))
  266. elif self.hit_matrix[y][x] == 5:
  267. s.blit(gra_files.gdic['display'][15],(((x-start)*32),(y-start)*32))
  268. elif self.hit_matrix[y][x] == 6:
  269. s.blit(gra_files.gdic['display'][23],(((x-start)*32),(y-start)*32))
  270. elif self.hit_matrix[y][x] == 7:
  271. s.blit(gra_files.gdic['display'][24],(((x-start)*32),(y-start)*32))
  272. elif self.hit_matrix[y][x] == 8:
  273. s.blit(gra_files.gdic['display'][26],(((x-start)*32),(y-start)*32))
  274. elif self.hit_matrix[y][x] == 9:
  275. s.blit(gra_files.gdic['display'][27],(((x-start)*32),(y-start)*32))
  276. elif self.hit_matrix[y][x] == 10:
  277. s.blit(gra_files.gdic['display'][42],(((x-start)*32),(y-start)*32))
  278. elif self.hit_matrix[y][x] == 11:
  279. s.blit(gra_files.gdic['display'][43],(((x-start)*32),(y-start)*32))
  280. elif self.hit_matrix[y][x] == 12:
  281. s.blit(gra_files.gdic['display'][51],(((x-start)*32),(y-start)*32))
  282. elif self.hit_matrix[y][x] == 13:
  283. s.blit(gra_files.gdic['display'][58],(((x-start)*32),(y-start)*32))
  284. elif self.hit_matrix[y][x] == 14:
  285. s.blit(gra_files.gdic['display'][59],(((x-start)*32),(y-start)*32))
  286. elif self.hit_matrix[y][x] == 15:
  287. s.blit(gra_files.gdic['display'][60],(((x-start)*32),(y-start)*32))
  288. elif self.hit_matrix[y][x] == 16:
  289. s.blit(gra_files.gdic['display'][61],(((x-start)*32),(y-start)*32))
  290. elif self.hit_matrix[y][x] == 17:
  291. s.blit(gra_files.gdic['display'][62],(((x-start)*32),(y-start)*32))
  292. elif self.hit_matrix[y][x] == 18:
  293. s.blit(gra_files.gdic['display'][63],(((x-start)*32),(y-start)*32))
  294. elif self.hit_matrix[y][x] == 19:
  295. s.blit(gra_files.gdic['display'][64],(((x-start)*32),(y-start)*32))
  296. elif self.hit_matrix[y][x] == 20:
  297. s.blit(gra_files.gdic['display'][65],(((x-start)*32),(y-start)*32))
  298. elif self.hit_matrix[y][x] == 21:
  299. s.blit(gra_files.gdic['display'][66],(((x-start)*32),(y-start)*32))
  300. elif self.hit_matrix[y][x] == 22:
  301. s.blit(gra_files.gdic['display'][67],(((x-start)*32),(y-start)*32))
  302. elif self.hit_matrix[y][x] == 23:
  303. s.blit(gra_files.gdic['display'][70],(((x-start)*32),(y-start)*32))
  304. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  305. s = s.convert_alpha()
  306. return s
  307. def render_main_menu(self,simulate=False):
  308. if simulate == False:
  309. screen.render_fade(False,True,'main')
  310. if home_save == False:
  311. display_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep
  312. alt_path = display_path
  313. else:
  314. display_path = os.path.expanduser('~') + os.sep + '.config' + os.sep + 'RogueBox-Adventures' + os.sep
  315. alt_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep
  316. num = 0
  317. master_loop = True
  318. run = True
  319. while run:
  320. s = pygame.Surface((640,360))
  321. s.fill((48,48,48))
  322. try:
  323. i_name = display_path + 'tmp.png'
  324. i = pygame.image.load(i_name)
  325. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  326. i = i.convert_alpha()
  327. s.blit(i,(0,0))
  328. except:
  329. i_name = alt_path + 'alt.png'
  330. i = pygame.image.load(i_name)
  331. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  332. i = i.convert_alpha()
  333. s.blit(i,(0,0))
  334. s.blit(gra_files.gdic['display'][16],(0,0))
  335. menu_list = ('PLAY','OPTIONS','CREDITS','QUIT')
  336. for c in range(0,len(menu_list)):
  337. name_image = self.font.render(menu_list[c],1,(0,0,0))
  338. s.blit(name_image,(210,145+(c*45)))
  339. s.blit(gra_files.gdic['display'][4],(185,138+(num*45)))
  340. version_info = 'v'+version+' "'+version_name+'"'
  341. ver_info_image1 = self.font.render(version_info,1,(0,0,0))
  342. ver_info_image2 = self.font.render(version_info,1,(255,255,255))
  343. s.blit(ver_info_image1,(107,85))
  344. s.blit(ver_info_image2,(105,85))
  345. if game_options.check_version == 1:
  346. if ver_string == 'This version is up to date.':
  347. ver_image = self.font.render(ver_string,1,(0,255,0))
  348. elif ver_string == 'Old version!!! Please update.':
  349. ver_image = self.font.render(ver_string,1,(255,0,0))
  350. else:
  351. ver_image = self.font.render(ver_string,1,(255,255,255))
  352. ver_image2 = self.font.render(ver_string,1,(0,0,0))
  353. s.blit(ver_image2,(12,340))
  354. s.blit(ver_image,(10,340))
  355. if game_options.mousepad == 0:
  356. s_h = pygame.Surface((160,360))
  357. s_h.fill((48,48,48))
  358. s.blit(s_h,(480,0))
  359. s_help = pygame.Surface((640,360))
  360. s_help.fill((48,48,48))
  361. s_help.blit(s,(80,0))
  362. s = s_help
  363. else:
  364. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  365. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  366. if simulate == True:
  367. return s
  368. self.screen.blit(s,(0,0))
  369. pygame.display.flip()
  370. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  371. if ui == 'exit':
  372. master_loop = False
  373. run = False
  374. if ui == 'w':
  375. num -= 1
  376. if num < 0:
  377. num = 0
  378. elif ui == 's':
  379. num += 1
  380. if num > 3:
  381. num = 3
  382. elif ui == 'e':
  383. if num == 0:
  384. test = screen.choose_save_path()
  385. if test == 'exit':
  386. master_loop = False
  387. run = False
  388. elif num == 1:
  389. test = screen.render_options()
  390. if test == 'exit':
  391. master_loop = False
  392. run = False
  393. elif num == 2:
  394. test = screen.render_credits()
  395. if test == 'exit':
  396. master_loop = False
  397. run = False
  398. elif num == 3:
  399. master_loop = False
  400. run = False
  401. return master_loop
  402. def render_crash(self):
  403. run = True
  404. while run:
  405. self.screen.fill((48,48,48))
  406. string = []
  407. string.append('Sorry, something went wrong.')
  408. string.append('Check out debug.txt for more informations.')
  409. debug_location = '('+save_path+')'
  410. for c in range(0,6):
  411. debug_location = debug_location.replace('World'+str(c),'debug.txt')
  412. string.append(debug_location)
  413. st = []
  414. for i in string:
  415. st.append(self.font.render(i,1,(255,255,255)))
  416. for j in range(0,len(st)):
  417. self.screen.blit(st[j],(5,25+j*25))
  418. pygame.display.flip()
  419. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  420. if ui != 'none':
  421. run = False
  422. def choose_save_path(self):
  423. global save_path
  424. global playing
  425. global master_loop
  426. global gra_files
  427. gra_files = g_files()
  428. if home_save == True:
  429. path = os.path.expanduser('~') + os.sep + '.config' + os.sep + 'RogueBox-Adventures'
  430. else:
  431. path = basic_path
  432. run = True
  433. while run:
  434. menu_items = []
  435. for c in range(0,5):
  436. save_path = path + os.sep + 'SAVE' + os.sep + 'World' + str(c)
  437. p_attribute = attribute(2,2,2,2,2,10,10)
  438. p_inventory = inventory()
  439. player_help = player_class ('-EMPTY SLOT-', 'local_0_0', p_attribute,p_inventory, build= 'Auto')
  440. if player_help.name != '-EMPTY SLOT-':
  441. item_string = player_help.name + ' LVL:' + str(player_help.lvl)
  442. else:
  443. item_string = '-EMPTY SLOT-'
  444. menu_items.append(item_string)
  445. menu_items.append('~~ERASE~~')
  446. menu_items.append('~~BACK~~')
  447. choice = screen.get_choice('Choose a saved game',menu_items,False)
  448. if choice == 'exit':
  449. master_loop = False
  450. run = False
  451. return('exit')
  452. if choice < 5:
  453. save_path = path + os.sep + 'SAVE' + os.sep + 'World' + str(choice)
  454. playing = True
  455. run = False
  456. elif choice == 5:
  457. menu_items_erase = []
  458. for d in range(0,5):
  459. menu_items_erase.append(menu_items[d])
  460. menu_items_erase.append('~~BACK~~')
  461. choice2 = screen.get_choice('Choose a game to erase',menu_items_erase,False,'Warning')
  462. if choice2 < 5:
  463. save_path = path + os.sep + 'SAVE' + os.sep + 'World' + str(choice2)
  464. try:
  465. choice3 = screen.get_choice('Are you sure?',('No','Yes'),False,'Warning')
  466. if choice3 == 1:
  467. h = ('world.data','time.data','player.data','gods.data')
  468. for i in h:
  469. p = save_path + os.sep + i
  470. os.remove(p)
  471. except:
  472. None
  473. elif choice == 6:
  474. run = False
  475. def save_tmp_png(self):
  476. x = player.pos[0]
  477. if x-10 < 0:
  478. x += -1*(x-11)
  479. elif x+10 > max_map_size-2:
  480. x -= 10
  481. y = player.pos[1]
  482. if y-10 < 0:
  483. y += -1*(y-11)
  484. elif y+10 > max_map_size-2:
  485. y -= 10
  486. z = player.pos[2]
  487. s = pygame.Surface((480,360))
  488. for yy in range(-5,10):
  489. for xx in range(-7,8):
  490. t_pos = world.maplist[z][player.on_map].tilemap[y+yy][x+xx].tile_pos
  491. t_replace = world.maplist[z][player.on_map].tilemap[y+yy][x+xx].replace
  492. if t_replace == None:
  493. s.blit(gra_files.gdic['tile32'][t_pos[1]][t_pos[0]],((xx+7)*32,(yy+5)*32))
  494. else:
  495. try:
  496. #render the replaced tile under the replacing one. eg.: for stacks
  497. s.blit(gra_files.gdic['tile32'][t_replace.tile_pos[1]][t_replace.tile_pos[0]],((xx+7)*32,(yy+5)*32))
  498. s.blit(gra_files.gdic['tile32'][t_pos[1]][t_pos[0]],((xx+7)*32,(yy+5)*32))
  499. except:
  500. None
  501. if home_save == False:
  502. tmp_save_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep + 'tmp.png'
  503. else:
  504. tmp_save_path = os.path.expanduser('~') + os.sep + '.config' + os.sep + 'RogueBox-Adventures' + os.sep + 'tmp.png'
  505. pygame.image.save(s,tmp_save_path)
  506. def re_init(self): # For changing screenmode
  507. options_path = save_path.replace(os.sep + 'World0','')
  508. if game_options.screenmode == 2 and cheat_mode == True:
  509. game_options.screenmode = 0
  510. mode = game_options.screenmode
  511. if self.win_mode < 2:
  512. mode += 1
  513. else:
  514. mode = 0
  515. if mode == 2 and cheat_mode == True:
  516. mode = 0
  517. game_options.screenmode = mode
  518. save_options(game_options,options_path,os.sep)
  519. self.__init__(game_options.screenmode,False)
  520. def draw_player(self):
  521. s = pygame.Surface((32,32))
  522. s.fill((255,0,255))
  523. if player.inventory.wearing['Background'] != player.inventory.nothing:
  524. 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))
  525. skinstring = 'SKIN_' + player.gender + '_' + str(player.style +1)
  526. s.blit(gra_files.gdic['char'][skinstring],(0,0))
  527. if player.inventory.wearing['Clothing'] == player.inventory.nothing:
  528. underwear_string = player.gender + '_underwear'
  529. s.blit(gra_files.gdic['char'][underwear_string],(0,0))
  530. try:
  531. render_hair = (player.inventory.wearing['Hat'].override_hair == False)
  532. except:
  533. render_hair = True
  534. if player.inventory.wearing['Head'] == player.inventory.nothing and render_hair:
  535. hairstring = 'HAIR_' + player.gender + '_' + str(player.style +1)
  536. s.blit(gra_files.gdic['char'][hairstring],(0,0))
  537. if player.inventory.wearing['Hat'] != player.inventory.nothing:
  538. 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))
  539. else:
  540. if player.inventory.wearing['Hat'] == player.inventory.nothing:
  541. if player.inventory.wearing['Head'] != player.inventory.nothing:
  542. helmetstring = player.gender + '_' + player.inventory.wearing['Head'].material + '_' + player.inventory.wearing['Head'].classe
  543. s.blit(gra_files.gdic['char'][helmetstring],(0,0))
  544. else:
  545. if render_hair == True:
  546. hairstring = 'HAIR_' + player.gender + '_' + str(player.style +1)
  547. s.blit(gra_files.gdic['char'][hairstring],(0,0))
  548. 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))
  549. if player.inventory.wearing['Clothing'] == player.inventory.nothing:
  550. if player.inventory.wearing['Body'] != player.inventory.nothing:
  551. armorstring = player.gender + '_' + player.inventory.wearing['Body'].material + '_' + player.inventory.wearing['Body'].classe
  552. s.blit(gra_files.gdic['char'][armorstring],(0,0))
  553. if player.inventory.wearing['Legs'] != player.inventory.nothing:
  554. cuissestring = player.gender + '_' + player.inventory.wearing['Legs'].material + '_' + player.inventory.wearing['Legs'].classe
  555. s.blit(gra_files.gdic['char'][cuissestring],(0,0))
  556. if player.inventory.wearing['Feet'] != player.inventory.nothing:
  557. shoestring = player.gender + '_' + player.inventory.wearing['Feet'].material + '_' + player.inventory.wearing['Feet'].classe
  558. s.blit(gra_files.gdic['char'][shoestring],(0,0))
  559. else:
  560. 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))
  561. if player.inventory.wearing['Hold(R)'] != player.inventory.nothing:
  562. weaponstring = 'WEAPONS_' + player.inventory.wearing['Hold(R)'].material + '_' + player.inventory.wearing['Hold(R)'].classe
  563. s.blit(gra_files.gdic['char'][weaponstring],(0,0))
  564. if player.inventory.wearing['Hold(L)'] != player.inventory.nothing:
  565. weaponstring = 'WEAPONS_' + player.inventory.wearing['Hold(L)'].material + '_' + player.inventory.wearing['Hold(L)'].classe
  566. s.blit(gra_files.gdic['char'][weaponstring],(0,0))
  567. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]][player.pos[0]].move_group == 'low_liquid':
  568. help_s = pygame.Surface((32,5))
  569. help_s.fill((255,0,255))
  570. s.blit(help_s,(0,27))
  571. elif world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]][player.pos[0]].move_group == 'swim':
  572. help_s = pygame.Surface((32,13))
  573. help_s.fill((255,0,255))
  574. s.blit(help_s,(0,19))
  575. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  576. return s
  577. def draw_tile(self,on_map,x,y,z,visible):
  578. s = pygame.Surface((32,32))
  579. s.fill((48,48,48))
  580. if x > max_map_size-1 or y > max_map_size-1 or x < 0 or y < 0:
  581. return s
  582. if world.maplist[z][on_map].known[y][x] == 0:
  583. s.blit(gra_files.gdic['tile32'][0][3],(0,0))
  584. else:
  585. if world.maplist[z][on_map].tilemap[y][x].replace != None:
  586. old_tile = world.maplist[z][on_map].tilemap[y][x]
  587. new_tile = world.maplist[z][on_map].tilemap[y][x]
  588. run = True
  589. while run:
  590. new_tile = old_tile.replace
  591. if new_tile != None:
  592. old_tile = new_tile
  593. else:
  594. run = False
  595. if len(old_tile.tile_pos) > 2:
  596. if time.minute%2 == 0:
  597. s.blit(gra_files.gdic['tile32'][old_tile.tile_pos[1]][old_tile.tile_pos[0]],(0,0))
  598. else:
  599. s.blit(gra_files.gdic['tile32'][old_tile.tile_pos[3]][old_tile.tile_pos[2]],(0,0))
  600. else:
  601. s.blit(gra_files.gdic['tile32'][old_tile.tile_pos[1]][old_tile.tile_pos[0]],(0,0))
  602. if len(world.maplist[z][on_map].tilemap[y][x].tile_pos) > 2:
  603. if time.minute%2 == 0:
  604. 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))
  605. else:
  606. 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))
  607. else:
  608. 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))
  609. if visible == False:
  610. s.blit(gra_files.gdic['display'][6],(0,0))
  611. if world.maplist[z][on_map].npcs[y][x] != 0:
  612. s.blit(self.draw_monster(x,y,z,on_map,visible),(0,0))
  613. return s
  614. def draw_monster(self,x,y,z,on_map,visible):
  615. s = pygame.Surface((32,32))
  616. s.fill((255,0,255))
  617. if visible == True:
  618. pos = world.maplist[z][on_map].npcs[y][x].sprite_pos
  619. s.blit(gra_files.gdic['monster'][pos[1]][pos[0]],(0,0))
  620. if world.maplist[z][on_map].tilemap[y][x].move_group == 'low_liquid':
  621. help_s = pygame.Surface((32,5))
  622. help_s.fill((255,0,255))
  623. s.blit(help_s,(0,27))
  624. elif world.maplist[z][on_map].tilemap[y][x].move_group == 'swim':
  625. help_s = pygame.Surface((32,13))
  626. help_s.fill((255,0,255))
  627. s.blit(help_s,(0,19))
  628. if world.maplist[z][on_map].npcs[y][x].move_border == 10:
  629. None
  630. elif world.maplist[z][on_map].npcs[y][x].AI_style == 'ignore':
  631. s.blit(gra_files.gdic['display'][28],(0,0))
  632. lvl = str(world.maplist[z][on_map].npcs[y][x].lvl)
  633. if len(lvl) == 1:
  634. lvl = '0'+lvl
  635. elif len(lvl) > 2:
  636. lvl = lvl[0]+'+'
  637. s.blit(gra_files.gdic['num'][lvl[0]],(0,6))
  638. s.blit(gra_files.gdic['num'][lvl[1]],(0,14))
  639. elif world.maplist[z][on_map].npcs[y][x].AI_style == 'flee':
  640. s.blit(gra_files.gdic['display'][29],(0,0))
  641. lvl = str(world.maplist[z][on_map].npcs[y][x].lvl)
  642. if len(lvl) == 1:
  643. lvl = '0'+lvl
  644. elif len(lvl) > 2:
  645. lvl = lvl[0]+'+'
  646. s.blit(gra_files.gdic['num'][lvl[0]],(0,6))
  647. s.blit(gra_files.gdic['num'][lvl[1]],(0,14))
  648. else:
  649. s.blit(gra_files.gdic['display'][30],(0,0))
  650. lvl = str(world.maplist[z][on_map].npcs[y][x].lvl)
  651. if len(lvl) == 1:
  652. lvl = '0'+lvl
  653. elif len(lvl) > 2:
  654. lvl = lvl[0]+'+'
  655. s.blit(gra_files.gdic['num'][lvl[0]],(0,6))
  656. s.blit(gra_files.gdic['num'][lvl[1]],(0,14))
  657. if world.maplist[z][on_map].npcs[y][x].move_border > 10:
  658. s.blit(gra_files.gdic['display'][69],(0,0))
  659. else:
  660. 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':
  661. pos = world.maplist[z][on_map].npcs[y][x].sprite_pos
  662. s.blit(gra_files.gdic['monster'][pos[1]][pos[0]],(0,0))
  663. else:
  664. coin = random.randint(0,1)
  665. if coin == 1:
  666. s.blit(gra_files.gdic['display'][7],(0,0))
  667. else:
  668. s.blit(gra_files.gdic['display'][6],(0,0))
  669. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  670. return s
  671. def generate_light_effect(self):
  672. if player.buffs.berzerk > 0:
  673. y = 3
  674. elif player.buffs.nightvision > 0:
  675. y = 2
  676. elif player.pos[2] > 0:
  677. y = 1
  678. else:
  679. y= 0
  680. x = time.hour
  681. if player.buffs.berzerk > 0:
  682. alpha = 135
  683. elif player.buffs.nightvision > 0:
  684. alpha = 60
  685. elif player.pos[2] == 0:
  686. if time.hour == 12:
  687. alpha = 0
  688. elif time.hour < 12:
  689. alpha = 60-(time.hour*5)
  690. elif time.hour > 12:
  691. alpha = 0+((time.hour-12)*5)
  692. else:
  693. alpha = 135
  694. light_color = gra_files.gdic['lightmap'].get_at((x,y))
  695. s = pygame.Surface((640,360))
  696. s.fill(light_color)
  697. if player.buffs.light > 0 and player.buffs.berzerk == 0:
  698. pygame.draw.circle(s,(255,0,255),[254,197],120,0)
  699. help_tile = pygame.Surface((32,32))
  700. help_tile.fill(light_color)
  701. fov = world.maplist[player.pos[2]][player.on_map].check_fov(player.pos[0],player.pos[1],6)
  702. for y in range(0,len(fov)-1):
  703. for x in range(0,len(fov[y])-1):
  704. if fov[y][x] == 0:
  705. s.blit(help_tile,(x*32,y*32))
  706. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  707. s.set_alpha(alpha)
  708. return s
  709. def render(self,mes_num, simulate = False, photo = False):
  710. radius = 6
  711. if player.pos[2] > 0:
  712. radius = 2
  713. elif player.pos[2] == 0:
  714. if time.hour > 22 or time.hour < 4:
  715. radius = 2
  716. elif time.hour > 21 or time.hour < 5:
  717. radius = 3
  718. elif time.hour > 20 or time.hour < 6:
  719. radius = 4
  720. elif time.hour > 19 or time.hour < 7:
  721. radius = 5
  722. if player.buffs.light > 0 or player.buffs.nightvision:
  723. radius = 6
  724. if player.buffs.blind > 0:
  725. radius = 0
  726. s = pygame.Surface((640,360))
  727. test = message.sget()
  728. s.fill((48,48,48)) #paint it grey(to clear the screen)
  729. start_pos_x = 240 #the center of the main map view
  730. start_pos_y = 180
  731. ymin = player.pos[1]-6
  732. ymax = player.pos[1]+6
  733. xmin = player.pos[0]-8
  734. xmax = player.pos[0]+7
  735. ry = 0
  736. fow = world.maplist[player.pos[2]][player.on_map].check_fov(player.pos[0],player.pos[1],radius)
  737. for y in range(ymin,ymax):
  738. rx = 0
  739. for x in range(xmin,xmax):
  740. s.blit(screen.draw_tile(player.on_map,x,y,player.pos[2],fow[ry][rx]),(rx*32,ry*32))
  741. if x == player.pos[0] and y == player.pos[1]:
  742. s.blit(screen.draw_player(),(rx*32,ry*32))
  743. player_pos_help = (x,y)
  744. rx+=1
  745. ry+=1
  746. s.blit(self.render_hits(),(0,0))
  747. s.blit(screen.generate_light_effect(),(0,0))
  748. if photo == True:
  749. if low_res == False:
  750. photo_help = pygame.Surface((480,360))
  751. photo_help.blit(s,(0,0))
  752. s = photo_help
  753. else:
  754. photo_help = pygame.Surface((320,240))
  755. photo_help.blit(s,(0,0))
  756. s = photo_help
  757. return s
  758. if self.fire_mode == 0:
  759. 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:
  760. s.blit(gra_files.gdic['display'][0],(0,0)) #render gui
  761. else:
  762. s.blit(gra_files.gdic['display'][25],(0,0)) #render gui_warning
  763. elif self.fire_mode == 1:
  764. s.blit(gra_files.gdic['display'][10],(0,0))
  765. 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))
  766. else:
  767. 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:
  768. s.blit(gra_files.gdic['display'][0],(0,0)) #render gui
  769. else:
  770. s.blit(gra_files.gdic['display'][25],(0,0)) #render gui_warning
  771. 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))
  772. #render tool info
  773. #1. Axe
  774. if player.inventory.wearing['Axe'] == player.inventory.nothing:
  775. s.blit(gra_files.gdic['display'][44],(0,39))
  776. else:
  777. s.blit(gra_files.gdic['display'][46],(0,39))
  778. axestring = 'WEAPONS_' + player.inventory.wearing['Axe'].material + '_' + player.inventory.wearing['Axe'].classe
  779. s.blit(gra_files.gdic['char'][axestring],(0,39))
  780. s.blit(gra_files.gdic['display'][47],(0,39))
  781. axe_state = (15*player.inventory.wearing['Axe'].state)/100
  782. help_sur = pygame.Surface((axe_state,1))
  783. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  784. s.blit(help_sur,(10,67))
  785. #2. Pickaxe
  786. if player.inventory.wearing['Pickaxe'] == player.inventory.nothing:
  787. s.blit(gra_files.gdic['display'][45],(16,39))
  788. else:
  789. s.blit(gra_files.gdic['display'][46],(16,39))
  790. pickaxestring = 'WEAPONS_' + player.inventory.wearing['Pickaxe'].material + '_' + player.inventory.wearing['Pickaxe'].classe
  791. s.blit(gra_files.gdic['char'][pickaxestring],(16,39))
  792. s.blit(gra_files.gdic['display'][47],(16,39))
  793. pickaxe_state = (15*player.inventory.wearing['Pickaxe'].state)/100
  794. help_sur = pygame.Surface((pickaxe_state,1))
  795. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  796. s.blit(help_sur,(26,67))
  797. #3. Melee weapon
  798. if player.inventory.wearing['Hold(R)'] == player.inventory.nothing:
  799. s.blit(gra_files.gdic['display'][52],(32,39))
  800. else:
  801. s.blit(gra_files.gdic['display'][46],(32,39))
  802. melee_string = 'WEAPONS_' + player.inventory.wearing['Hold(R)'].material + '_' + player.inventory.wearing['Hold(R)'].classe
  803. if player.inventory.wearing['Hold(R)'].classe != 'spear':
  804. s.blit(gra_files.gdic['char'][melee_string],(32,39))
  805. else:
  806. h_sur = pygame.Surface((32,19))
  807. h_sur.fill((255,0,255))
  808. h_sur.blit(gra_files.gdic['char'][melee_string],(0,0))
  809. h_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  810. h_sur = h_sur.convert_alpha()
  811. s.blit(h_sur,(39,48))
  812. s.blit(gra_files.gdic['display'][47],(32,39))
  813. melee_state = (15*player.inventory.wearing['Hold(R)'].state)/100
  814. help_sur = pygame.Surface((melee_state,1))
  815. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  816. s.blit(help_sur,(42,67))
  817. #4. Magic weapon
  818. if player.inventory.wearing['Hold(L)'] == player.inventory.nothing:
  819. s.blit(gra_files.gdic['display'][53],(48,39))
  820. else:
  821. s.blit(gra_files.gdic['display'][46],(48,39))
  822. magic_string = 'WEAPONS_' + player.inventory.wearing['Hold(L)'].material + '_' + player.inventory.wearing['Hold(L)'].classe
  823. if player.inventory.wearing['Hold(L)'].classe != 'rune staff':
  824. s.blit(gra_files.gdic['char'][magic_string],(42,39))
  825. else:
  826. h_sur = pygame.Surface((32,19))
  827. h_sur.fill((255,0,255))
  828. h_sur.blit(gra_files.gdic['char'][magic_string],(0,0))
  829. h_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  830. h_sur = h_sur.convert_alpha()
  831. s.blit(h_sur,(42,48))
  832. s.blit(gra_files.gdic['display'][47],(48,39))
  833. magic_state = (15*player.inventory.wearing['Hold(L)'].state)/100
  834. help_sur = pygame.Surface((magic_state,1))
  835. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  836. s.blit(help_sur,(58,67))
  837. #5. Necklace
  838. if player.inventory.wearing['Neck'] == player.inventory.nothing:
  839. s.blit(gra_files.gdic['display'][40],(64,39))
  840. else:
  841. s.blit(gra_files.gdic['display'][46],(64,39))
  842. necklacestring = 'WEAPONS_' + player.inventory.wearing['Neck'].material + '_' + player.inventory.wearing['Neck'].classe
  843. s.blit(gra_files.gdic['char'][necklacestring],(64,39))
  844. s.blit(gra_files.gdic['display'][47],(64,39))
  845. necklace_state = (15*player.inventory.wearing['Neck'].state)/100
  846. help_sur = pygame.Surface((necklace_state,1))
  847. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  848. s.blit(help_sur,(74,67))
  849. #6. Helmet
  850. if player.inventory.wearing['Head'] == player.inventory.nothing:
  851. s.blit(gra_files.gdic['display'][54],(0,54))
  852. else:
  853. s.blit(gra_files.gdic['display'][46],(0,54))
  854. helmet_string = player.gender + '_' + player.inventory.wearing['Head'].material + '_' + player.inventory.wearing['Head'].classe
  855. h_sur = pygame.Surface((32,32))
  856. h_sur.fill((255,0,255))
  857. h_sur.blit(gra_files.gdic['char'][helmet_string],(0,0))
  858. pygame.draw.rect(h_sur,(255,0,255),(0,0,10,32),0)
  859. pygame.draw.rect(h_sur,(255,0,255),(0,0,32,4),0)
  860. pygame.draw.rect(h_sur,(255,0,255),(25,0,7,32),0)
  861. h_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  862. h_sur = h_sur.convert_alpha()
  863. s.blit(h_sur,(0,65))
  864. s.blit(gra_files.gdic['display'][47],(0,54))
  865. helmet_state = (15*player.inventory.wearing['Head'].state)/100
  866. help_sur = pygame.Surface((helmet_state,1))
  867. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  868. s.blit(help_sur,(10,82))
  869. #7. Armor
  870. if player.inventory.wearing['Body'] == player.inventory.nothing:
  871. s.blit(gra_files.gdic['display'][55],(16,54))
  872. else:
  873. s.blit(gra_files.gdic['display'][46],(16,54))
  874. armor_string = player.gender + '_' + player.inventory.wearing['Body'].material + '_' + player.inventory.wearing['Body'].classe
  875. h_sur = pygame.Surface((32,32))
  876. h_sur.fill((255,0,255))
  877. h_sur.blit(gra_files.gdic['char'][armor_string],(0,0))
  878. pygame.draw.rect(h_sur,(255,0,255),(0,0,10,32),0)
  879. pygame.draw.rect(h_sur,(255,0,255),(25,0,7,32),0)
  880. h_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  881. h_sur = h_sur.convert_alpha()
  882. s.blit(h_sur,(16,55))
  883. s.blit(gra_files.gdic['display'][47],(16,54))
  884. armor_state = (15*player.inventory.wearing['Body'].state)/100
  885. help_sur = pygame.Surface((armor_state,1))
  886. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  887. s.blit(help_sur,(26,82))
  888. #8. Cuisse
  889. if player.inventory.wearing['Legs'] == player.inventory.nothing:
  890. s.blit(gra_files.gdic['display'][56],(32,54))
  891. else:
  892. s.blit(gra_files.gdic['display'][46],(32,54))
  893. cuisse_string = player.gender + '_' + player.inventory.wearing['Legs'].material + '_' + player.inventory.wearing['Legs'].classe
  894. s.blit(gra_files.gdic['char'][cuisse_string],(32,50))
  895. s.blit(gra_files.gdic['display'][47],(32,54))
  896. cuisse_state = (15*player.inventory.wearing['Legs'].state)/100
  897. help_sur = pygame.Surface((cuisse_state,1))
  898. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  899. s.blit(help_sur,(42,82))
  900. #9. Shoes
  901. if player.inventory.wearing['Feet'] == player.inventory.nothing:
  902. s.blit(gra_files.gdic['display'][57],(48,54))
  903. else:
  904. s.blit(gra_files.gdic['display'][46],(48,54))
  905. shoes_string = player.gender + '_' + player.inventory.wearing['Feet'].material + '_' + player.inventory.wearing['Feet'].classe
  906. s.blit(gra_files.gdic['char'][shoes_string],(49,46))
  907. s.blit(gra_files.gdic['display'][47],(48,54))
  908. shoes_state = (15*player.inventory.wearing['Feet'].state)/100
  909. help_sur = pygame.Surface((shoes_state,1))
  910. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  911. s.blit(help_sur,(58,82))
  912. #10. Ring
  913. if player.inventory.wearing['Hand'] == player.inventory.nothing:
  914. s.blit(gra_files.gdic['display'][39],(64,54))
  915. else:
  916. s.blit(gra_files.gdic['display'][46],(64,54))
  917. ring_string = 'WEAPONS_' + player.inventory.wearing['Hand'].material + '_' + player.inventory.wearing['Hand'].classe
  918. s.blit(gra_files.gdic['char'][ring_string],(64,54))
  919. s.blit(gra_files.gdic['display'][47],(64,54))
  920. ring_state = (15*player.inventory.wearing['Hand'].state)/100
  921. help_sur = pygame.Surface((ring_state,1))
  922. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  923. s.blit(help_sur,(74,82))
  924. #render icons
  925. #1. Use
  926. 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:
  927. s.blit(gra_files.gdic['display'][32],(0,161))
  928. s.blit(gra_files.gdic['display'][34],(0,161))
  929. else:
  930. s.blit(gra_files.gdic['display'][31],(0,161))
  931. s.blit(gra_files.gdic['display'][33],(0,161))
  932. use_string = '['+key_name['e']+']action'
  933. use_image1 = self.font.render(use_string,1,(0,0,0))
  934. use_image2 = self.font.render(use_string,1,(255,255,255))
  935. s.blit(use_image1,(36,173))
  936. s.blit(use_image2,(34,173))
  937. #2. Fire
  938. if player.inventory.wearing['Hold(L)'] == player.inventory.nothing or player.mp < 2:
  939. s.blit(gra_files.gdic['display'][32],(0,129))
  940. s.blit(gra_files.gdic['display'][36],(0,129))
  941. else:
  942. s.blit(gra_files.gdic['display'][31],(0,129))
  943. s.blit(gra_files.gdic['display'][35],(0,129))
  944. if self.fire_mode == False:
  945. fire_string = '['+key_name['f']+']fire'
  946. else:
  947. fire_string = '['+key_name['x']+']cancel'
  948. fire_image1 = self.font.render(fire_string,1,(0,0,0))
  949. fire_image2 = self.font.render(fire_string,1,(255,255,255))
  950. s.blit(fire_image1,(36,141))
  951. s.blit(fire_image2,(34,141))
  952. #4.Focus
  953. s.blit(gra_files.gdic['display'][32],(0,97))#65
  954. try:
  955. focus_state = (32*player.mp/player.attribute.max_mp)
  956. except:
  957. focus_state = 1
  958. help_sur = pygame.Surface((focus_state,32))
  959. help_sur.fill((255,0,255))
  960. help_sur.blit(gra_files.gdic['display'][31],(0,0))
  961. help_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  962. help_sur = help_sur.convert_alpha()
  963. s.blit(help_sur,(0,97))
  964. if player.mp < player.attribute.max_mp:
  965. s.blit(gra_files.gdic['display'][38],(0,97))
  966. focus_string = 'unfocused'
  967. else:
  968. s.blit(gra_files.gdic['display'][37],(0,97))
  969. focus_string = 'focused'
  970. focus_image1 = self.font.render(focus_string,1,(0,0,0))
  971. focus_image2 = self.font.render(focus_string,1,(255,255,255))
  972. s.blit(focus_image1,(36,109))#77
  973. s.blit(focus_image2,(34,109))
  974. # render messages
  975. if low_res == False:
  976. mes_pos_y = 335
  977. else:
  978. mes_pos_y = 225
  979. mlist = test
  980. for c in range(0,5):
  981. shadow_image = self.font.render(mlist[c],1,(0,0,0))
  982. text_image = self.font.render(mlist[c],1,(255,255,255))
  983. s.blit(shadow_image,(2,mes_pos_y-(c*10)))
  984. s.blit(text_image,(0,mes_pos_y-(c*10)))
  985. #render lvl info
  986. lvl_string = str(player.lvl)
  987. if len(lvl_string) == 1:
  988. lvl_string = '0'+lvl_string
  989. lvl_image = self.font.render(lvl_string,1,(255,255,255))
  990. s.blit(lvl_image,(153,48))
  991. bar_length = 1 + ((319/100)*player.xp)
  992. xp_surface = pygame.Surface((bar_length,64))
  993. xp_surface.fill((255,0,255))
  994. xp_surface.blit(gra_files.gdic['display'][19],(0,0))
  995. xp_surface.set_colorkey((255,0,255),pygame.RLEACCEL)
  996. xp_surface = xp_surface.convert_alpha()
  997. s.blit(xp_surface,(0,0))
  998. if game_options.mousepad == 1:
  999. if self.fire_mode == 0:
  1000. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  1001. else:
  1002. s.blit(gra_files.gdic['display'][9],(480,0))
  1003. else:
  1004. s_help = pygame.Surface((160,360))
  1005. s_help.fill((48,48,48))
  1006. s.blit(s_help,(480,0))
  1007. #render buffs
  1008. buffs = player.buffs.sget()
  1009. if low_res == False:
  1010. posx = 388
  1011. posy = 10
  1012. else:
  1013. posx = 228
  1014. posy = 75
  1015. for i in buffs:
  1016. if i != ' ':
  1017. buff_shadow = self.font.render(i,1,(0,0,0))
  1018. s.blit(buff_shadow,(posx+2,posy))
  1019. buff_image = self.font.render(i,1,(200,200,200))
  1020. s.blit(buff_image,(posx,posy))
  1021. else:
  1022. None
  1023. posy += 20
  1024. #render date
  1025. date_string = time.sget()
  1026. posx = 235
  1027. posy = 10
  1028. date_image = self.font.render(date_string[0],1,(0,0,0))
  1029. s.blit(date_image,(posx,posy))
  1030. posy = 20
  1031. time_image = self.font.render(date_string[1],1,(0,0,0))
  1032. s.blit(time_image,(posx,posy))
  1033. #render player info
  1034. #lp
  1035. lp_string = str(player.lp) + '/' + str(player.attribute.max_lp)
  1036. posx = 13
  1037. posy = 12
  1038. if player.lp < 4:
  1039. lp_image = self.font.render(lp_string,1,(200,0,0))
  1040. else:
  1041. lp_image = self.font.render(lp_string,1,(0,0,0))
  1042. s.blit(lp_image,(posx,posy))
  1043. #hunger
  1044. hunger_percent = int((100 * player.attribute.hunger) / player.attribute.hunger_max)
  1045. hunger_string = str(hunger_percent) + '%'
  1046. posx = 75
  1047. posy = 12
  1048. if hunger_percent < 11:
  1049. hunger_image = self.font.render(hunger_string,1,(200,0,0))
  1050. else:
  1051. hunger_image = self.font.render(hunger_string,1,(0,0,0))
  1052. s.blit(hunger_image,(posx,posy))
  1053. #trirst
  1054. thirst_percent = int((100 * player.attribute.thirst) / player.attribute.thirst_max)
  1055. thirst_string = str(thirst_percent) + '%'
  1056. posx = 125
  1057. posy = 12
  1058. if thirst_percent < 11:
  1059. thirst_image = self.font.render(thirst_string,1,(200,0,0))
  1060. else:
  1061. thirst_image = self.font.render(thirst_string,1,(0,0,0))
  1062. s.blit(thirst_image,(posx,posy))
  1063. #tiredness
  1064. tiredness_percent = int((100 * player.attribute.tiredness) / player.attribute.tiredness_max)
  1065. tiredness_string = str(tiredness_percent) + '%'
  1066. posx = 180
  1067. posy = 12
  1068. if tiredness_percent < 11:
  1069. tiredness_image = self.font.render(tiredness_string,1,(200,0,0))
  1070. else:
  1071. tiredness_image = self.font.render(tiredness_string,1,(0,0,0))
  1072. s.blit(tiredness_image,(posx,posy))
  1073. if game_options.mousepad == 0:
  1074. s_help = pygame.Surface((640,360))
  1075. s_help.fill((48,48,48))
  1076. s_help.blit(s,(80,0))
  1077. s = s_help
  1078. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1079. self.screen.blit(s,(0,0))
  1080. if simulate == False:
  1081. pygame.display.flip()
  1082. else:
  1083. return s
  1084. if test[1] == '~*~':
  1085. return True
  1086. else:
  1087. return False
  1088. def render_load(self,num,progress=None):
  1089. s = pygame.Surface((640,360))
  1090. s.fill((48,48,48)) #paint it grey(to clear the screen)
  1091. if num == 0:
  1092. string = 'Looking for saved data... '
  1093. elif num == 1:
  1094. string = 'Loading world data...'
  1095. elif num == 2:
  1096. string = 'Nothing found...'
  1097. elif num == 3:
  1098. string = 'Generate overworld...'
  1099. elif num == 4:
  1100. string = 'Generate caves...'
  1101. elif num == 5:
  1102. string = 'Saving...'
  1103. elif num == 6:
  1104. string = 'Loading time data...'
  1105. elif num == 7:
  1106. string = 'Loading player data...'
  1107. elif num == 8:
  1108. string = 'Set time...'
  1109. elif num == 9:
  1110. string = 'Generate player...'
  1111. elif num == 10:
  1112. string = 'Making time related changes...'
  1113. elif num == 11:
  1114. string = 'Something has gone wrong...'
  1115. elif num == 12:
  1116. string = 'Zzzzzzzzzz'
  1117. elif num == 13:
  1118. string = 'Generate deus ex machina...'
  1119. elif num == 14:
  1120. string = 'Loading deus ex machina...'
  1121. elif num == 15:
  1122. string = 'Generate grot...'
  1123. elif num == 16:
  1124. string = 'Generate elfish fortress...'
  1125. elif num == 17:
  1126. string = 'Generate orcish mines...'
  1127. elif num == 18:
  1128. string = 'Generate desert...'
  1129. elif num == 19:
  1130. string = 'Initialize level...'
  1131. elif num == 20:
  1132. string = 'Please use run.py/run.exe'
  1133. ######add more here
  1134. if low_res == False:
  1135. posx = 150
  1136. posy = 200
  1137. else:
  1138. posx=50
  1139. posy= 100
  1140. image = self.font.render(string,1,(255,255,255))
  1141. s.blit(image,(posx,posy))
  1142. if progress != None:
  1143. s.blit(gra_files.gdic['display'][20],(posx-50,posy+20))
  1144. help_sur = pygame.Surface((((progress*320)/100),12))
  1145. help_sur.fill((255,0,255))
  1146. help_sur.blit(gra_files.gdic['display'][21],(0,0))
  1147. help_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  1148. help_sur = help_sur.convert_alpha()
  1149. s.blit(help_sur,(posx-50,posy+20))
  1150. if low_res == False:
  1151. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1152. self.screen.blit(s,(0,0))
  1153. pygame.display.flip()
  1154. def render_built(self,xmin,xmax,ymin,ymax,style):
  1155. start_pos_x = 256 #the center of the main map view
  1156. start_pos_y = 192
  1157. price = 0
  1158. self.render(0, False)
  1159. s = pygame.Surface((640,360))
  1160. s.fill((255,0,255))
  1161. if style == 'wall':
  1162. for y in range (-ymin,ymax+1):
  1163. for x in range (-xmin,xmax+1):
  1164. 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:
  1165. built_here = 1
  1166. price += 2
  1167. elif world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].civilisation == True:
  1168. built_here = 2
  1169. price += 1
  1170. else:
  1171. built_here = 0
  1172. if world.maplist[player.pos[2]][player.on_map].npcs[player.pos[1]+y][player.pos[0]+x] != 0:
  1173. built_here = False
  1174. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].build_here == False:
  1175. if built_here == 1:
  1176. price -= 2
  1177. elif built_here == 2:
  1178. price -= 1
  1179. built_here = 0
  1180. if built_here != 0:
  1181. if x == xmax or x == -xmin or y == ymax or y == -ymin:
  1182. if x == xmax or x == -xmin:
  1183. if built_here == 1:
  1184. s.blit(gra_files.gdic['built'][1],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_true here
  1185. elif built_here == 2:
  1186. s.blit(gra_files.gdic['built'][6],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_over here
  1187. if y == ymax or y == -ymin:
  1188. if built_here == 1:
  1189. s.blit(gra_files.gdic['built'][1],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_true here
  1190. elif built_here == 2:
  1191. s.blit(gra_files.gdic['built'][6],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_over here
  1192. else:
  1193. None
  1194. else:
  1195. if x == xmax or x == -xmin or y == ymax or y == -ymin:
  1196. if x == xmax or x == -xmin:
  1197. s.blit(gra_files.gdic['built'][0],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_false here
  1198. if y == ymax or y == -ymin:
  1199. s.blit(gra_files.gdic['built'][0],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_false here
  1200. else:
  1201. None
  1202. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1203. # render mode name
  1204. name = '~Build Walls~'
  1205. name_image = self.font.render(name,1,(255,255,255))
  1206. posx = 0
  1207. posy = 0
  1208. s.blit(name_image,(posx,posy))
  1209. # render wood needed
  1210. wood_need = int(price/3)
  1211. if wood_need == 0:
  1212. wood_need = 1
  1213. wood_string = 'Wood: ' + str(wood_need) + '(' + str(player.inventory.materials.wood) + ')'
  1214. posx = 0
  1215. posy = 15
  1216. if wood_need <= player.inventory.materials.wood:
  1217. wood_image = self.font.render(wood_string,1,(255,255,255))
  1218. else:
  1219. wood_image = self.font.render(wood_string,1,(200,0,0))
  1220. s.blit(wood_image,(posx,posy))
  1221. # render stone needed
  1222. stone_need = int(price/2)
  1223. if stone_need == 0:
  1224. stone_need = 1
  1225. stone_string = 'Stone: ' + str(stone_need) + '(' + str(player.inventory.materials.stone) + ')'
  1226. posx = 160
  1227. posy = 15
  1228. if stone_need <= player.inventory.materials.stone:
  1229. stone_image = self.font.render(stone_string,1,(255,255,255))
  1230. else:
  1231. stone_image = self.font.render(stone_string,1,(200,0,0))
  1232. s.blit(stone_image,(posx,posy))
  1233. # render info line
  1234. info_string_0 = '['+key_name['wasd']+']ch. Size ['+key_name['b']+']ch. Mode'
  1235. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']BUILT!'
  1236. posx = 0
  1237. posy = 30
  1238. info_image = self.font.render(info_string_0,1,(255,255,255))
  1239. s.blit(info_image,(posx,posy))
  1240. posx = 0
  1241. posy = 40
  1242. info_image = self.font.render(info_string_1,1,(255,255,255))
  1243. s.blit(info_image,(posx,posy))
  1244. elif style == 'floor':
  1245. for y in range (-ymin,ymax+1):
  1246. for x in range (-xmin,xmax+1):
  1247. 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:
  1248. built_here = 1
  1249. price += 2
  1250. elif world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].civilisation == True:
  1251. built_here = 2
  1252. price += 1
  1253. else:
  1254. built_here = 0
  1255. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].build_here == False:
  1256. if built_here == 1:
  1257. price -= 2
  1258. elif built_here == 2:
  1259. price -= 1
  1260. built_here = 0
  1261. if built_here != 0:
  1262. if built_here == 1:
  1263. s.blit(gra_files.gdic['built'][5],(start_pos_x+(x*32),start_pos_y+(y*32))) #floor_true here
  1264. elif built_here == 2:
  1265. s.blit(gra_files.gdic['built'][7],(start_pos_x+(x*32),start_pos_y+(y*32))) #floor_over
  1266. else:
  1267. s.blit(gra_files.gdic['built'][4],(start_pos_x+(x*32),start_pos_y+(y*32))) #floor_false here
  1268. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1269. # render mode name
  1270. name = '~Build Floor~'
  1271. name_image = self.font.render(name,1,(255,255,255))
  1272. posx = 0
  1273. posy = 0
  1274. s.blit(name_image,(posx,posy))
  1275. # render wood needed
  1276. wood_need = int(price/2)
  1277. if wood_need == 0:
  1278. wood_need = 1
  1279. wood_string = 'Wood: ' + str(wood_need) + '(' + str(player.inventory.materials.wood) + ')'
  1280. posx = 0
  1281. posy = 15
  1282. if wood_need <= player.inventory.materials.wood:
  1283. wood_image = self.font.render(wood_string,1,(255,255,255))
  1284. else:
  1285. wood_image = self.font.render(wood_string,1,(200,0,0))
  1286. s.blit(wood_image,(posx,posy))
  1287. # render stone needed
  1288. stone_need = int(price/3)
  1289. if stone_need == 0:
  1290. stone_need = 1
  1291. stone_string = 'Stone: ' + str(stone_need) + '(' + str(player.inventory.materials.stone) + ')'
  1292. posx = 160
  1293. posy = 15
  1294. if stone_need <= player.inventory.materials.stone:
  1295. stone_image = self.font.render(stone_string,1,(255,255,255))
  1296. else:
  1297. stone_image = self.font.render(stone_string,1,(200,0,0))
  1298. s.blit(stone_image,(posx,posy))
  1299. # render info line
  1300. info_string_0 = '['+key_name['wasd']+']ch. Size ['+key_name['b']+']ch. Mode'
  1301. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']BUILT!'
  1302. posx = 0
  1303. posy = 30
  1304. info_image = self.font.render(info_string_0,1,(255,255,255))
  1305. s.blit(info_image,(posx,posy))
  1306. posx = 0
  1307. posy = 40
  1308. info_image = self.font.render(info_string_1,1,(255,255,255))
  1309. s.blit(info_image,(posx,posy))
  1310. elif style == 'Door':
  1311. 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:
  1312. built_here = 1
  1313. price += 2
  1314. elif world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].civilisation == True:
  1315. built_here = 2
  1316. price += 1
  1317. else:
  1318. built_here = 0
  1319. if world.maplist[player.pos[2]][player.on_map].npcs[player.pos[1]+ymin][player.pos[0]+xmin] != 0:
  1320. built_here = False
  1321. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].build_here == False:
  1322. if built_here == 1:
  1323. price -= 2
  1324. elif built_here == 2:
  1325. price -= 1
  1326. built_here = 0
  1327. if built_here != 0:
  1328. if built_here == 1:
  1329. s.blit(gra_files.gdic['built'][3],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #door_true here
  1330. elif built_here == 2:
  1331. s.blit(gra_files.gdic['built'][8],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #door_over
  1332. else:
  1333. s.blit(gra_files.gdic['built'][2],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #door_false here
  1334. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1335. # render mode name
  1336. name = '~Built Door~'
  1337. name_image = self.font.render(name,1,(255,255,255))
  1338. posx = 0
  1339. posy = 0
  1340. s.blit(name_image,(posx,posy))
  1341. # render wood needed
  1342. wood_need = price
  1343. wood_string = 'Wood: ' + str(wood_need) + '(' + str(player.inventory.materials.wood) + ')'
  1344. posx = 0
  1345. posy = 15
  1346. if wood_need <= player.inventory.materials.wood:
  1347. wood_image = self.font.render(wood_string,1,(255,255,255))
  1348. else:
  1349. wood_image = self.font.render(wood_string,1,(200,0,0))
  1350. s.blit(wood_image,(posx,posy))
  1351. # render stone needed
  1352. stone_need = 0
  1353. stone_string = 'Stone: ' + str(stone_need) + '(' + str(player.inventory.materials.stone) + ')'
  1354. posx = 160
  1355. posy = 15
  1356. if stone_need <= player.inventory.materials.stone:
  1357. stone_image = self.font.render(stone_string,1,(255,255,255))
  1358. else:
  1359. stone_image = self.font.render(stone_string,1,(200,0,0))
  1360. s.blit(stone_image,(posx,posy))
  1361. # render info line
  1362. info_string_0 = '['+key_name['wasd']+']ch. Pos. ['+key_name['b']+']ch. Mode'
  1363. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']BUILT!'
  1364. posx = 0
  1365. posy = 30
  1366. info_image = self.font.render(info_string_0,1,(255,255,255))
  1367. s.blit(info_image,(posx,posy))
  1368. posx = 0
  1369. posy = 40
  1370. info_image = self.font.render(info_string_1,1,(255,255,255))
  1371. s.blit(info_image,(posx,posy))
  1372. pygame.display.flip()
  1373. elif style == 'Stair up':
  1374. if player.pos[2] > 0:
  1375. 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:
  1376. build_here = 0
  1377. else:
  1378. build_here = 1
  1379. if build_here == 0:
  1380. s.blit(gra_files.gdic['built'][10],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #stair up true icon here
  1381. else:
  1382. s.blit(gra_files.gdic['built'][11],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #stair up false icon here
  1383. else:
  1384. s.blit(gra_files.gdic['built'][11],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #stair up false icon here
  1385. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1386. # render mode name
  1387. name = '~Built stair up~'
  1388. name_image = self.font.render(name,1,(255,255,255))
  1389. posx = 0
  1390. posy = 0
  1391. s.blit(name_image,(posx,posy))
  1392. # render wood needed
  1393. wood_need = 10
  1394. wood_string = 'Wood: ' + str(wood_need) + '(' + str(player.inventory.materials.wood) + ')'
  1395. posx = 0
  1396. posy = 15
  1397. if wood_need <= player.inventory.materials.wood:
  1398. wood_image = self.font.render(wood_string,1,(255,255,255))
  1399. else:
  1400. wood_image = self.font.render(wood_string,1,(200,0,0))
  1401. s.blit(wood_image,(posx,posy))
  1402. # render stone needed
  1403. stone_need = 40
  1404. stone_string = 'Stone: ' + str(stone_need) + '(' + str(player.inventory.materials.stone) + ')'
  1405. posx = 160
  1406. posy = 15
  1407. if stone_need <= player.inventory.materials.stone:
  1408. stone_image = self.font.render(stone_string,1,(255,255,255))
  1409. else:
  1410. stone_image = self.font.render(stone_string,1,(200,0,0))
  1411. s.blit(stone_image,(posx,posy))
  1412. # render info line
  1413. info_string_0 = '['+key_name['wasd']+']ch. Pos. ['+key_name['b']+']ch. Mode'
  1414. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']BUILT!'
  1415. posx = 0
  1416. posy = 30
  1417. info_image = self.font.render(info_string_0,1,(255,255,255))
  1418. s.blit(info_image,(posx,posy))
  1419. posx = 0
  1420. posy = 40
  1421. info_image = self.font.render(info_string_1,1,(255,255,255))
  1422. s.blit(info_image,(posx,posy))
  1423. pygame.display.flip()
  1424. elif style == 'Stair down':
  1425. if player.pos[2] < 15:
  1426. 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:
  1427. build_here = 0
  1428. else:
  1429. build_here = 1
  1430. if build_here == 0:
  1431. s.blit(gra_files.gdic['built'][12],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #stair up true icon here
  1432. else:
  1433. s.blit(gra_files.gdic['built'][13],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #stair up false icon here
  1434. else:
  1435. s.blit(gra_files.gdic['built'][12],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #stair up false icon here
  1436. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1437. # render mode name
  1438. name = '~Built stair down~'
  1439. name_image = self.font.render(name,1,(255,255,255))
  1440. posx = 0
  1441. posy = 0
  1442. s.blit(name_image,(posx,posy))
  1443. # render wood needed
  1444. wood_need = 10
  1445. wood_string = 'Wood: ' + str(wood_need) + '(' + str(player.inventory.materials.wood) + ')'
  1446. posx = 0
  1447. posy = 15
  1448. if wood_need <= player.inventory.materials.wood:
  1449. wood_image = self.font.render(wood_string,1,(255,255,255))
  1450. else:
  1451. wood_image = self.font.render(wood_string,1,(200,0,0))
  1452. s.blit(wood_image,(posx,posy))
  1453. # render stone needed
  1454. if player.pos[2] > 0:
  1455. stone_need = 40
  1456. else:
  1457. stone_need = 15
  1458. stone_string = 'Stone: ' + str(stone_need) + '(' + str(player.inventory.materials.stone) + ')'
  1459. posx = 160
  1460. posy = 15
  1461. if stone_need <= player.inventory.materials.stone:
  1462. stone_image = self.font.render(stone_string,1,(255,255,255))
  1463. else:
  1464. stone_image = self.font.render(stone_string,1,(200,0,0))
  1465. s.blit(stone_image,(posx,posy))
  1466. # render info line
  1467. info_string_0 = '['+key_name['wasd']+']ch. Pos. ['+key_name['b']+']ch. Mode'
  1468. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']BUILT!'
  1469. posx = 0
  1470. posy = 30
  1471. info_image = self.font.render(info_string_0,1,(255,255,255))
  1472. s.blit(info_image,(posx,posy))
  1473. posx = 0
  1474. posy = 40
  1475. info_image = self.font.render(info_string_1,1,(255,255,255))
  1476. s.blit(info_image,(posx,posy))
  1477. pygame.display.flip()
  1478. elif style == 'Agriculture':
  1479. for y in range (-ymin,ymax+1):
  1480. for x in range (-xmin,xmax+1):
  1481. 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:
  1482. built_here = 1
  1483. price += 1
  1484. elif world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].civilisation == True:
  1485. built_here = 2
  1486. price += 1
  1487. else:
  1488. built_here = 0
  1489. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].build_here == False:
  1490. if built_here == 1:
  1491. price -= 2
  1492. elif built_here == 2:
  1493. price -= 1
  1494. built_here = 0
  1495. if built_here != 0:
  1496. if built_here == 1:
  1497. s.blit(gra_files.gdic['built'][15],(start_pos_x+(x*32),start_pos_y+(y*32))) #floor_true here
  1498. elif built_here == 2:
  1499. s.blit(gra_files.gdic['built'][16],(start_pos_x+(x*32),start_pos_y+(y*32))) #floor_over
  1500. else:
  1501. s.blit(gra_files.gdic['built'][14],(start_pos_x+(x*32),start_pos_y+(y*32))) #floor_false here
  1502. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1503. # render mode name
  1504. name = '~Build Agriculture~'
  1505. name_image = self.font.render(name,1,(255,255,255))
  1506. posx = 0
  1507. posy = 0
  1508. s.blit(name_image,(posx,posy))
  1509. # render seeds needed
  1510. seed_need = price
  1511. if seed_need == 0:
  1512. seed_need = 1
  1513. wood_need = seed_need
  1514. stone_need = 0
  1515. wood_string = 'Seeds: ' + str(seed_need) + '(' + str(player.inventory.materials.seeds) + ')'
  1516. posx = 120
  1517. posy = 15
  1518. if wood_need <= player.inventory.materials.wood:
  1519. wood_image = self.font.render(wood_string,1,(255,255,255))
  1520. else:
  1521. wood_image = self.font.render(wood_string,1,(200,0,0))
  1522. s.blit(wood_image,(posx,posy))
  1523. # render info line
  1524. info_string_0 = '['+key_name['wasd']+']ch. Size ['+key_name['b']+']ch. Mode'
  1525. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']BUILT!'
  1526. posx = 0
  1527. posy = 30
  1528. info_image = self.font.render(info_string_0,1,(255,255,255))
  1529. s.blit(info_image,(posx,posy))
  1530. posx = 0
  1531. posy = 40
  1532. info_image = self.font.render(info_string_1,1,(255,255,255))
  1533. s.blit(info_image,(posx,posy))
  1534. elif style == 'remove':
  1535. for y in range (-ymin,ymax+1):
  1536. for x in range (-xmin,xmax+1):
  1537. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].civilisation == True and world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].build_here == True:
  1538. remove_here = 0
  1539. else:
  1540. remove_here = 1
  1541. if remove_here == 0:
  1542. s.blit(gra_files.gdic['built'][9],(start_pos_x+(x*32),start_pos_y+(y*32))) #remove icon here
  1543. else:
  1544. None
  1545. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1546. # render mode name
  1547. name = '~Remove~'
  1548. name_image = self.font.render(name,1,(255,255,255))
  1549. posx = 0
  1550. posy = 0
  1551. s.blit(name_image,(posx,posy))
  1552. # render ---
  1553. wood_string = '---'
  1554. posx = 120
  1555. posy = 15
  1556. wood_image = self.font.render(wood_string,1,(255,255,255))
  1557. s.blit(wood_image,(posx,posy))
  1558. # render info line
  1559. info_string_0 = '['+key_name['wasd']+']ch. Size ['+key_name['b']+']ch. Mode'
  1560. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']REMOVE!'
  1561. posx = 0
  1562. posy = 30
  1563. info_image = self.font.render(info_string_0,1,(255,255,255))
  1564. s.blit(info_image,(posx,posy))
  1565. posx = 0
  1566. posy = 40
  1567. info_image = self.font.render(info_string_1,1,(255,255,255))
  1568. s.blit(info_image,(posx,posy))
  1569. wood_need = 0
  1570. stone_need = 0
  1571. if game_options.mousepad == 0 and low_res == False:
  1572. s_help = pygame.Surface((640,360))
  1573. s_help.fill((255,0,255))
  1574. s_help.blit(s,(80,0))
  1575. s = s_help
  1576. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  1577. s = s.convert_alpha()
  1578. if low_res == False:
  1579. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1580. self.screen.blit(s,(0,0))
  1581. pygame.display.flip()
  1582. return (wood_need,stone_need)
  1583. def render_place(self,tile,use_name):
  1584. global player
  1585. x = player.pos[0]
  1586. y = player.pos[1]
  1587. start_pos_x = 256 #the center of the main map view
  1588. start_pos_y = 192
  1589. run = True
  1590. while run:
  1591. lootable = False
  1592. placeable = True
  1593. plantable = False
  1594. #1: check if lootable
  1595. for i in range(9,14):
  1596. if tile.techID == tl.tlist['functional'][i].techID:#this is a workbench
  1597. lootable = True
  1598. if tile.use_group == 'gather':
  1599. lootable = True
  1600. #2: check if placeable
  1601. if world.maplist[player.pos[2]][player.on_map].tilemap[y][x].move_group != 'soil':
  1602. placeable = False
  1603. if world.maplist[player.pos[2]][player.on_map].tilemap[y][x].replace != None:
  1604. placeable = False
  1605. if world.maplist[player.pos[2]][player.on_map].npcs[y][x] != 0:
  1606. placeable = False
  1607. if tile.move_group != 'soil':
  1608. if x == player.pos[0] and y == player.pos[1]:
  1609. placeable = False
  1610. #2.5: check if plantable
  1611. if world.maplist[player.pos[2]][player.on_map].tilemap[y][x].can_grown == True:
  1612. plantable = True
  1613. if use_name != 'plant':
  1614. plantable = True #if the object to be placeced no plant plantable is always true
  1615. #3: render
  1616. self.render(0,True)
  1617. s = pygame.Surface((640,360))
  1618. s.fill((255,0,255))
  1619. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1620. string1 ='~'+tile.name+'~'
  1621. string1_image = self.font.render(string1,1,(255,255,255))
  1622. s.blit(string1_image,(0,0))
  1623. if lootable == False:
  1624. warning = self.font.render('Can\'t be moved later!',1,(200,0,0))
  1625. s.blit(warning,(0,20))
  1626. string2 = '['+key_name['wasd']+']Move ['+key_name['e']+']Place! ['+key_name['x']+']Leave'
  1627. string2_image = self.font.render(string2,1,(255,255,255))
  1628. s.blit(string2_image,(0,40))
  1629. xx = x - player.pos[0]
  1630. yy = y - player.pos[1]
  1631. if placeable == True and plantable == True:
  1632. s.blit(gra_files.gdic['built'][18],(start_pos_x+(xx*32),start_pos_y+(yy*32)))
  1633. else:
  1634. s.blit(gra_files.gdic['built'][17],(start_pos_x+(xx*32),start_pos_y+(yy*32)))
  1635. if game_options.mousepad == 0:
  1636. s_help = pygame.Surface((640,360))
  1637. s_help.fill((255,0,255))
  1638. s_help.blit(s,(80,0))
  1639. s = s_help
  1640. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  1641. s = s.convert_alpha()
  1642. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1643. self.screen.blit(s,(0,0))
  1644. pygame.display.flip()
  1645. #4: user input
  1646. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  1647. if ui == 'exit':
  1648. global master_loop
  1649. global playing
  1650. global exitgame
  1651. exitgame = True
  1652. try:
  1653. save_options(game_options,options_path,os.sep)
  1654. screen.render_load(5)
  1655. save(world,player,time,gods,save_path,os.sep)
  1656. screen.save_tmp_png()
  1657. del player
  1658. except:
  1659. None
  1660. master_loop = False
  1661. playing = False
  1662. run = False
  1663. return('exit')
  1664. if ui == 'w':
  1665. if y > 0 and y > player.pos[1]-2:
  1666. y -= 1
  1667. elif ui == 's':
  1668. if y < max_map_size-1 and y < player.pos[1]+2:
  1669. y += 1
  1670. elif ui == 'a':
  1671. if x > 0 and x > player.pos[0]-2:
  1672. x -= 1
  1673. elif ui == 'd':
  1674. if x < max_map_size-1 and x < player.pos[0]+2:
  1675. x += 1
  1676. elif ui == 'e':
  1677. if placeable == True and plantable == True:
  1678. replace = world.maplist[player.pos[2]][player.on_map].tilemap[y][x]
  1679. world.maplist[player.pos[2]][player.on_map].tilemap[y][x] = deepcopy(tile)
  1680. world.maplist[player.pos[2]][player.on_map].tilemap[y][x].replace = deepcopy(replace)
  1681. world.maplist[player.pos[2]][player.on_map].tilemap[y][x].civilisation = True
  1682. if use_name == 'plant':
  1683. mes = 'You planted a '+tile.name+'.'
  1684. else:
  1685. mes = 'You placed a '+tile.name+'.'
  1686. message.add(mes)
  1687. return(x,y)
  1688. elif ui == 'x':
  1689. run = False
  1690. return False
  1691. return False#only to be sure
  1692. def render_textbox_open(self):
  1693. clock = pygame.time.Clock()
  1694. for i in range(-64,1,3):
  1695. s = pygame.Surface((320,240))
  1696. s.fill((255,0,255))
  1697. s.blit(gra_files.gdic['display'][5],(0,i)) #render gui_transparent over gui
  1698. if game_options.mousepad == 0:
  1699. s_help = pygame.Surface((640,360))
  1700. s_help.fill((255,0,255))
  1701. s_help.blit(s,(80,0))
  1702. s = s_help
  1703. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  1704. s = s.convert_alpha()
  1705. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1706. self.screen.blit(s,(0,0))
  1707. pygame.display.flip()
  1708. clock.tick(256)
  1709. def render_request(self,line1,line2,line3,first_call=True):
  1710. #this function just renders 3 lines of text in the textbox
  1711. self.render(0, True)
  1712. if first_call == True:
  1713. self.render_textbox_open()
  1714. s = pygame.Surface((320,240))
  1715. s.fill((255,0,255))
  1716. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1717. # render lines
  1718. line1_image = self.font.render(line1,1,(255,255,255))
  1719. posx = 0
  1720. posy = 0
  1721. s.blit(line1_image,(posx,posy))
  1722. line2_image = self.font.render(line2,1,(255,255,255))
  1723. posx = 0
  1724. posy = 20
  1725. s.blit(line2_image,(posx,posy))
  1726. line3_image = self.font.render(line3,1,(255,255,255))
  1727. posx = 0
  1728. posy = 40
  1729. s.blit(line3_image,(posx,posy))
  1730. if game_options.mousepad == 0:
  1731. s_help = pygame.Surface((640,360))
  1732. s_help.fill((255,0,255))
  1733. s_help.blit(s,(80,0))
  1734. s = s_help
  1735. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  1736. s = s.convert_alpha()
  1737. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1738. self.screen.blit(s,(0,0))
  1739. pygame.display.flip()
  1740. def render_map(self,level=0):
  1741. run = True
  1742. while run:
  1743. m = pygame.Surface((max_map_size,max_map_size))
  1744. for y in range(0,max_map_size):
  1745. for x in range(0,max_map_size):
  1746. try:
  1747. t_col = world.maplist[level][player.on_map].tilemap[y][x].tile_color
  1748. except:
  1749. level = 0
  1750. t_col = world.maplist[level][player.on_map].tilemap[y][x].tile_color
  1751. 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
  1752. m.blit(gra_files.gdic['tile1']['white'],(x,y))
  1753. else:
  1754. if world.maplist[level][player.on_map].known[y][x] == 1:
  1755. m.blit(gra_files.gdic['tile1'][t_col],(x,y))
  1756. elif world.maplist[level][player.on_map].known[y][x] == 0:
  1757. m.blit(gra_files.gdic['tile1']['black'],(x,y))
  1758. else:
  1759. m.blit(gra_files.gdic['tile1']['black'],(x,y))
  1760. m = pygame.transform.scale(m,(270,270))
  1761. s = pygame.Surface((640,360))
  1762. bg = pygame.Surface((480,360))
  1763. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  1764. s.blit(bg,(0,0))
  1765. if game_options.mousepad == 1:
  1766. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  1767. else:
  1768. s_help = pygame.Surface((160,360))
  1769. s_help.fill((48,48,48))
  1770. s.blit(s_help,(480,0))
  1771. text = '~Map~ [Press['+key_name['x']+'] to leave'
  1772. text_image = screen.font.render(text,1,(255,255,255))
  1773. s.blit(text_image,(5,2))#menue title
  1774. lvl_string = 'Level ' + str(level)
  1775. text_image = screen.font.render(lvl_string,1,(0,0,0))
  1776. if low_res == False:
  1777. s.blit(text_image,(300,70))
  1778. else:
  1779. s.blit(text_image,(190,50))
  1780. s.blit(m,(25,55))
  1781. if game_options.mousepad == 0:
  1782. s_help = pygame.Surface((640,360))
  1783. s_help.fill((48,48,48))
  1784. s_help.blit(s,(80,0))
  1785. s = s_help
  1786. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1787. self.screen.blit(s,(0,0))
  1788. pygame.display.flip()
  1789. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  1790. if ui == 'exit':
  1791. global master_loop
  1792. global playing
  1793. global exitgame
  1794. exitgame = True
  1795. screen.render_load(5)
  1796. save(world,player,time,gods,save_path,os.sep)
  1797. screen.save_tmp_png()
  1798. master_loop = False
  1799. playing = False
  1800. run = False
  1801. return('exit')
  1802. if ui == 'x':
  1803. run = False
  1804. def render_credits(self):
  1805. global master_loop
  1806. run = True
  1807. while run:
  1808. s = pygame.Surface((640,360))
  1809. bg = pygame.Surface((480,360))
  1810. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  1811. s.blit(bg,(0,0))
  1812. if game_options.mousepad == 1 and low_res == False:
  1813. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  1814. else:
  1815. s_help = pygame.Surface((160,360))
  1816. s_help.fill((48,48,48))
  1817. s.blit(s_help,(480,0))
  1818. text = '~Credits~ [Press ['+key_name['x']+'] to leave]'
  1819. text_image = screen.font.render(text,1,(255,255,255))
  1820. s.blit(text_image,(5,2))#menue title
  1821. credit_items = ('Code & Art: The Mighty Glider', 'BGM: Various Artists [CC0]' , 'SFX: Various Artists [CC0]', 'Font: Cody Boisclair', 'Testing: eugeneloza', 'Special Thanks: forum.freegamedev.net', ' !freegaming@quitter.se')
  1822. for i in range (0,len(credit_items)):
  1823. text_image = screen.font.render(credit_items[i],1,(0,0,0))
  1824. s.blit(text_image,(21,120+i*25))#blit credit_items
  1825. if game_options.mousepad == 0:
  1826. s_help = pygame.Surface((640,360))
  1827. s_help.fill((48,48,48))
  1828. s_help.blit(s,(80,0))
  1829. s = s_help
  1830. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1831. self.screen.blit(s,(0,0))
  1832. pygame.display.flip()
  1833. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  1834. if ui == 'exit':
  1835. master_loop = False
  1836. run = False
  1837. return('exit')
  1838. if ui == 'x':
  1839. run = False
  1840. def render_status(self):
  1841. player_attribute = ('Strength: '+str(player.attribute.p_strength),
  1842. 'Skill: '+str(player.attribute.p_defense),
  1843. 'Power: '+str(player.attribute.m_strength),
  1844. 'Will: '+str(player.attribute.m_defense),
  1845. 'Health: '+str(player.lp)+'/'+str(player.attribute.max_lp),
  1846. '--> SKILLS')
  1847. attribute_info = ('Strength','Skill','Power','Will','Health')
  1848. if player.skill.woodcutting == 'Novice':
  1849. woodcutting_next_lvl = '200'
  1850. else:
  1851. woodcutting_next_lvl = '1000'
  1852. if player.skill.mining == 'Novice':
  1853. mining_next_lvl = '200'
  1854. else:
  1855. mining_next_lvl = '1000'
  1856. player_skills = ('Weapon Crafting: '+player.skill.weapon_crafting,
  1857. 'Metallurgy: '+player.skill.metallurgy,
  1858. 'Alchemy: '+player.skill.alchemy,
  1859. 'Woodcutting: '+player.skill.woodcutting+' ('+str(player.skill.woodcutting_progress)+'/'+woodcutting_next_lvl+')',
  1860. 'Mining: '+player.skill.mining+' ('+str(player.skill.mining_progress)+'/'+mining_next_lvl+')',
  1861. '<-- ATTRIBUTE')
  1862. skill_info = ('Weapon Crafting','Metallurgy','Alchemy','Woodcutting','Mining')
  1863. run = True
  1864. while run:
  1865. c = screen.get_choice('Attributes',player_attribute,True)
  1866. if c == 'Break':
  1867. run = False
  1868. return False
  1869. if c < 5:
  1870. screen.render_text(texts[attribute_info[c]])
  1871. elif c == 5:
  1872. run2 = True
  1873. while run2:
  1874. d = screen.get_choice('Skills',player_skills,True)
  1875. if d == 'Break':
  1876. run = False
  1877. run2 = False
  1878. return False
  1879. if d < 5:
  1880. screen.render_text(texts[skill_info[d]])
  1881. elif d == 5:
  1882. run2 = False
  1883. def render_text(self,text,replace_keys=True,more_txt=False,simulation= False):
  1884. run = True
  1885. while run:
  1886. if low_res == False:
  1887. s = pygame.Surface((640,360))
  1888. else:
  1889. s = pygame.Surface((320,240))
  1890. bg = pygame.Surface((480,360))
  1891. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  1892. if low_res == True:
  1893. bg = pygame.transform.scale(bg,(320,240))
  1894. s.blit(bg,(0,0))
  1895. if game_options.mousepad == 1 and low_res == False:
  1896. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  1897. else:
  1898. s_help = pygame.Surface((160,360))
  1899. s_help.fill((48,48,48))
  1900. s.blit(s_help,(480,0))
  1901. if simulation == False:
  1902. if more_txt == False:
  1903. top_text = '[Press ['+key_name['x']+'] to leave]'
  1904. else:
  1905. top_text = '[Press ['+key_name['e']+'] for next page]'
  1906. text_image = screen.font.render(top_text,1,(255,255,255))
  1907. s.blit(text_image,(5,2))#menue title
  1908. for i in range (0,len(text)):
  1909. text_image = screen.font.render(text[i],1,(0,0,0))
  1910. if low_res == False:
  1911. s.blit(text_image,(60,80+i*25))#blit credit_items
  1912. else:
  1913. s.blit(text_image,(21,36+i*20))#blit credit_items
  1914. if simulation == True:
  1915. return s
  1916. if game_options.mousepad == 0 and low_res == False:
  1917. s_help = pygame.Surface((640,360))
  1918. s_help.fill((48,48,48))
  1919. s_help.blit(s,(80,0))
  1920. s = s_help
  1921. if low_res == False:
  1922. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1923. self.screen.blit(s,(0,0))
  1924. pygame.display.flip()
  1925. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  1926. if ui == 'exit':
  1927. global master_loop
  1928. global playing
  1929. global exitgame
  1930. exitgame = True
  1931. try:
  1932. screen.render_load(5)
  1933. save(world,player,time,gods,save_path,os.sep)
  1934. screen.save_tmp_png()
  1935. del player
  1936. except:
  1937. None
  1938. master_loop = False
  1939. playing = False
  1940. run = False
  1941. return('exit')
  1942. if ui == 'x':
  1943. run = False
  1944. elif ui == 'e' and more_txt == True:
  1945. run = False
  1946. def render_multi_text(self,texts):
  1947. run = True
  1948. page = 0
  1949. total_pages = len(texts)
  1950. while run:
  1951. s = self.render_text(texts[page],simulation=True)
  1952. page_txt = 'Page '+str(page+1)+ ' of '+str(total_pages)+' ['+key_name['x']+'] - leave'
  1953. page_image = screen.font.render(page_txt,1,(255,255,255))
  1954. s.blit(page_image,(5,2))#menue title
  1955. if game_options.mousepad == 0 and low_res == False:
  1956. s_help = pygame.Surface((640,360))
  1957. s_help.fill((48,48,48))
  1958. s_help.blit(s,(80,0))
  1959. s = s_help
  1960. if low_res == False:
  1961. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1962. self.screen.blit(s,(0,0))
  1963. pygame.display.flip()
  1964. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  1965. if ui == 's' or ui == 'd':
  1966. page += 1
  1967. if page > total_pages-1:
  1968. page = 0
  1969. elif ui == 'w' or ui == 'a':
  1970. page -= 1
  1971. if page < 0:
  1972. page = total_pages-1
  1973. elif ui == 'x':
  1974. run = False
  1975. def render_options(self):
  1976. run = True
  1977. num = 0
  1978. options_path = save_path
  1979. for c in range(0,5):
  1980. options_path = options_path.replace(os.sep + 'World' + str(c),'')
  1981. while run:
  1982. if game_options.screenmode == 2:
  1983. winm = 'Screenmode: Fullscreen'
  1984. elif game_options.screenmode == 1:
  1985. winm = 'Screenmode: Windowed(1280X720)'
  1986. else:
  1987. winm = 'Screenmode: Windowed(640X360)'
  1988. if game_options.bgmmode == 1:
  1989. audiom = 'BGM: ON'
  1990. else:
  1991. audiom = 'BGM: OFF'
  1992. if game_options.sfxmode == 1:
  1993. sfxm = 'SFX: ON'
  1994. else:
  1995. sfxm = 'SFX: OFF'
  1996. if game_options.turnmode == 1:
  1997. turnm = 'Gamemode: Semi-Realtime'
  1998. else:
  1999. turnm = 'Gamemode: Turnbased'
  2000. if game_options.mousepad == 1:
  2001. mousem = 'Use Mouse: yes'
  2002. else:
  2003. mousem = 'Use Mouse: no'
  2004. if game_options.check_version == 1:
  2005. versm = 'Check Version: yes'
  2006. else:
  2007. versm = 'Check Version: no'
  2008. s = pygame.Surface((640,360))
  2009. bg = pygame.Surface((480,360))
  2010. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  2011. if low_res == True:
  2012. bg = pygame.transform.scale(bg,(320,240))
  2013. s.blit(bg,(0,0))
  2014. text = '~Options~ [Press ['+key_name['e']+'] to choose]'
  2015. text_image = screen.font.render(text,1,(255,255,255))
  2016. s.blit(text_image,(5,2))#menue title
  2017. menu_items = (winm,audiom,sfxm,turnm,mousem,versm,'Done')
  2018. for i in range (0,len(menu_items)):
  2019. text_image = screen.font.render(menu_items[i],1,(0,0,0))
  2020. s.blit(text_image,(21,120+i*25))#blit menu_items
  2021. s.blit(gra_files.gdic['display'][4],(0,112+num*25))#blit marker
  2022. if game_options.mousepad == 1:
  2023. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2024. else:
  2025. s_help = pygame.Surface((160,360))
  2026. s_help.fill((48,48,48))
  2027. s.blit(s_help,(480,0))
  2028. if game_options.mousepad == 0:
  2029. s_help = pygame.Surface((640,360))
  2030. s_help.fill((48,48,48))
  2031. s_help.blit(s,(80,0))
  2032. s = s_help
  2033. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  2034. self.screen.blit(s,(0,0))
  2035. pygame.display.flip()
  2036. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2037. if ui == 'exit':
  2038. global master_loop
  2039. global playing
  2040. global exitgame
  2041. global player
  2042. exitgame = True
  2043. try:
  2044. save_options(game_options,options_path,os.sep)
  2045. screen.render_load(5)
  2046. save(world,player,time,gods,save_path,os.sep)
  2047. screen.save_tmp_png()
  2048. del player
  2049. except:
  2050. None
  2051. master_loop = False
  2052. playing = False
  2053. run = False
  2054. return('exit')
  2055. if ui == 'w':
  2056. num -= 1
  2057. if num < 0:
  2058. num = len(menu_items)-1
  2059. if ui == 's':
  2060. num += 1
  2061. if num >= len(menu_items):
  2062. num = 0
  2063. if ui == 'x':
  2064. run = False
  2065. if ui == 'e':
  2066. if num == 0:
  2067. screen.re_init()
  2068. pygame.display.flip()
  2069. save_options(game_options,options_path,os.sep)
  2070. if num == 1:
  2071. if game_options.bgmmode == 1:
  2072. game_options.bgmmode = 0
  2073. pygame.mixer.music.pause()
  2074. else:
  2075. game_options.bgmmode = 1
  2076. pygame.mixer.music.unpause()
  2077. bgm.check_for_song(force_play=True)
  2078. save_options(game_options,options_path,os.sep)
  2079. if num == 2:
  2080. if game_options.sfxmode == 1:
  2081. game_options.sfxmode = 0
  2082. else:
  2083. game_options.sfxmode = 1
  2084. save_options(game_options,options_path,os.sep)
  2085. if num == 3:
  2086. if game_options.turnmode == 1:
  2087. game_options.turnmode = 0
  2088. else:
  2089. game_options.turnmode = 1
  2090. save_options(game_options,options_path,os.sep)
  2091. if num == 4 and low_res == False:
  2092. if game_options.mousepad == 1:
  2093. game_options.mousepad = 0
  2094. else:
  2095. game_options.mousepad = 1
  2096. pygame.mouse.set_visible(game_options.mousepad)
  2097. save_options(game_options,options_path,os.sep)
  2098. if num == 5:
  2099. if game_options.check_version == 1:
  2100. game_options.check_version = 0
  2101. else:
  2102. game_options.check_version = 1
  2103. save_options(game_options,options_path,os.sep)
  2104. if num == 6:
  2105. save_options(game_options,options_path,os.sep)
  2106. run = False
  2107. def render_brake(self,simulate= False):
  2108. run = True
  2109. num = 0
  2110. global exitgame
  2111. global playing
  2112. global player
  2113. while run:
  2114. if low_res == False:
  2115. s = pygame.Surface((640,360))
  2116. else:
  2117. s = pygame.Surface((320,240))
  2118. bg = pygame.Surface((480,360))
  2119. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  2120. if low_res == True:
  2121. bg = pygame.transform.scale(bg,(320,240))
  2122. s.blit(bg,(0,0))
  2123. text = '~Game Paused~ [Press ['+key_name['e']+'] to choose]'
  2124. text_image = screen.font.render(text,1,(255,255,255))
  2125. s.blit(text_image,(5,2))#menue title
  2126. menu_items = ('Resume','Status','Message History','Save and Exit', 'Options',)
  2127. for i in range (0,len(menu_items)):
  2128. text_image = screen.font.render(menu_items[i],1,(0,0,0))
  2129. if low_res == False:
  2130. s.blit(text_image,(21,120+i*25))#blit menu_items
  2131. else:
  2132. s.blit(text_image,(21,46+i*25))#blit menu_items
  2133. if low_res == False:
  2134. s.blit(gra_files.gdic['display'][4],(0,112+num*25))#blit marker
  2135. else:
  2136. s.blit(gra_files.gdic['display'][4],(0,38+num*25))#blit marker
  2137. if game_options.mousepad == 1 and low_res != True:
  2138. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2139. else:
  2140. s_help = pygame.Surface((160,360))
  2141. s_help.fill((48,48,48))
  2142. s.blit(s_help,(480,0))
  2143. if game_options.mousepad == 0 and low_res == False:
  2144. s_help = pygame.Surface((640,360))
  2145. s_help.fill((48,48,48))
  2146. s_help.blit(s,(80,0))
  2147. s = s_help
  2148. if low_res == False:
  2149. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  2150. if simulate == True:
  2151. return s
  2152. self.screen.blit(s,(0,0))
  2153. pygame.display.flip()
  2154. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2155. if ui == 'exit':
  2156. global master_loop
  2157. global playing
  2158. global exitgame
  2159. exitgame = True
  2160. screen.render_load(5)
  2161. save(world,player,time,gods,save_path,os.sep)
  2162. screen.save_tmp_png()
  2163. master_loop = False
  2164. playing = False
  2165. run = False
  2166. return('exit')
  2167. if ui == 'w':
  2168. num -= 1
  2169. if num < 0:
  2170. num = len(menu_items)-1
  2171. if ui == 's':
  2172. num += 1
  2173. if num >= len(menu_items):
  2174. num = 0
  2175. if ui == 'x':
  2176. run = False
  2177. screen.render_fade(True,False,'screen')
  2178. if ui == 'e':
  2179. if num == 0:
  2180. run = False
  2181. screen.render_fade(True,False,'screen')
  2182. if num == 1:
  2183. screen.render_status()
  2184. if num == 2:
  2185. do = message.render_history()
  2186. if do == 'exit':
  2187. run = False
  2188. if num == 3:
  2189. exitgame = True
  2190. screen.render_load(5)
  2191. save(world,player,time,gods,save_path,os.sep)
  2192. screen.save_tmp_png()
  2193. del player
  2194. playing = False
  2195. run = False
  2196. if num == 4:
  2197. do = screen.render_options()
  2198. if do == 'exit':
  2199. run = False
  2200. return exitgame
  2201. def get_choice(self,headline,choices,allow_chancel,style='Default'):
  2202. #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
  2203. run = True
  2204. num = 0
  2205. while run:
  2206. if low_res == False:
  2207. s = pygame.Surface((640,360))
  2208. else:
  2209. s = pygame.Surface((320,240))
  2210. bg = pygame.Surface((480,360))
  2211. if style == 'Default':
  2212. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  2213. elif style == 'Warning':
  2214. bg.blit(gra_files.gdic['display'][17],(0,0))
  2215. if low_res == True:
  2216. bg = pygame.transform.scale(bg,(320,240))
  2217. s.blit(bg,(0,0))
  2218. text_image = screen.font.render(headline,1,(255,255,255))
  2219. if low_res == False:
  2220. s.blit(text_image,(5,2))#menue title
  2221. else:
  2222. s.blit(text_image,(0,2))#menue title
  2223. menu_items = choices
  2224. for i in range (0,len(menu_items)):
  2225. text_image = screen.font.render(menu_items[i],1,(0,0,0))
  2226. if low_res == False:
  2227. s.blit(text_image,(21,120+i*25))#blit menu_items
  2228. else:
  2229. s.blit(text_image,(21,46+i*25))#blit menu_items
  2230. if allow_chancel == True:
  2231. string = '['+key_name['e']+'] - choose ['+key_name['x']+'] - leave'
  2232. text_image = screen.font.render(string,1,(255,255,255))
  2233. if low_res == True:
  2234. s.blit(text_image,(0,225))
  2235. else:
  2236. s.blit(text_image,(5,335))
  2237. else:
  2238. string = '['+key_name['e']+'] - choose'
  2239. text_image = screen.font.render(string,1,(255,255,255))
  2240. if low_res == True:
  2241. s.blit(text_image,(0,225))
  2242. else:
  2243. s.blit(text_image,(5,335))
  2244. if style == 'Default':
  2245. if low_res == False:
  2246. s.blit(gra_files.gdic['display'][4],(0,112+num*25))#blit marker
  2247. else:
  2248. s.blit(gra_files.gdic['display'][4],(0,38+num*25))#blit marker
  2249. elif style == 'Warning':
  2250. if low_res == False:
  2251. s.blit(gra_files.gdic['display'][18],(0,112+num*25))#blit marker
  2252. else:
  2253. s.blit(gra_files.gdic['display'][18],(0,38+num*25))#blit marker
  2254. if game_options.mousepad == 1 and low_res == True:
  2255. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2256. else:
  2257. s_help = pygame.Surface((160,360))
  2258. s_help.fill((48,48,48))
  2259. s.blit(s_help,(480,0))
  2260. if game_options.mousepad == 0 and low_res == False:
  2261. s_help = pygame.Surface((640,360))
  2262. s_help.fill((48,48,48))
  2263. s_help.blit(s,(80,0))
  2264. s = s_help
  2265. else:
  2266. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2267. if low_res == False:
  2268. s = pygame.transform.scale(s,(screen.displayx,screen.displayy))
  2269. screen.screen.blit(s,(0,0))
  2270. pygame.display.flip()
  2271. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2272. if ui == 'exit':
  2273. global master_loop
  2274. global playing
  2275. global exitgame
  2276. global player
  2277. exitgame = True
  2278. try:
  2279. screen.render_load(5)
  2280. save(world,player,time,gods,save_path,os.sep)
  2281. screen.save_tmp_png()
  2282. except:
  2283. None
  2284. master_loop = False
  2285. playing = False
  2286. run = False
  2287. return('exit')
  2288. if ui == 'w':
  2289. num -= 1
  2290. if num < 0:
  2291. num = len(menu_items)-1
  2292. if ui == 's':
  2293. num += 1
  2294. if num >= len(menu_items):
  2295. num = 0
  2296. if ui == 'e':
  2297. run = False
  2298. return num
  2299. if ui == 'x' and allow_chancel == True:
  2300. run = False
  2301. return 'Break'
  2302. def string_input(self, input_message, length):
  2303. run = True
  2304. string = ''
  2305. pos = 0
  2306. x = 0
  2307. y = 0
  2308. 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', '.',','),('(','[','<','{',')',']','>','}','#','+','-','_','*','/','&','%'))
  2309. while run:
  2310. s = pygame.Surface((640,360))
  2311. s.blit(gra_files.gdic['display'][1],(0,0)) #render background
  2312. text_image = screen.font.render(input_message,1,(255,255,255))
  2313. s.blit(text_image,(5,2))#menue title
  2314. num_stars = length - len(string)
  2315. star_string = ''
  2316. if num_stars > 0:
  2317. for i in range (0,num_stars):
  2318. star_string += '*'
  2319. shown_string = string + '_' + star_string
  2320. string_image = screen.font.render(shown_string,1,(255,255,255))
  2321. s.blit(string_image,(5,35))#string so far
  2322. for i in range (0,5):#blit chars
  2323. for j in range (0,len(char_field[1])):
  2324. if i == y and j == x:
  2325. char_image = screen.font.render(char_field[i][j],1,(255,255,255))
  2326. else:
  2327. char_image = screen.font.render(char_field[i][j],1,(0,0,0))
  2328. if low_res == False:
  2329. s.blit(char_image,(55+(j*20),150+(i*20)))
  2330. else:
  2331. s.blit(char_image,(5+(j*20),90+(i*20)))
  2332. if game_options.mousepad == 1 and low_res == False:
  2333. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2334. else:
  2335. s_help = pygame.Surface((160,360))
  2336. s_help.fill((48,48,48))
  2337. s.blit(s_help,(480,0))
  2338. text = '['+key_name['e']+'] - Add Char ['+key_name['x']+'] - Del Char ['+key_name['b']+'] - Done'
  2339. text_image = screen.font.render(text,1,(255,255,255))
  2340. if low_res == False:
  2341. s.blit(text_image,(5,335))
  2342. else:
  2343. help_sur = pygame.Surface((320,16))
  2344. help_sur.fill((48,48,48))
  2345. help_sur.blit(text_image,(5,5))
  2346. s.blit(help_sur,(0,224))
  2347. if game_options.mousepad == 0 and low_res == False:
  2348. s_help = pygame.Surface((640,360))
  2349. s_help.fill((48,48,48))
  2350. s_help.blit(s,(80,0))
  2351. s = s_help
  2352. if low_res == False:
  2353. s = pygame.transform.scale(s,(screen.displayx,screen.displayy))
  2354. screen.screen.blit(s,(0,0))
  2355. pygame.display.flip()
  2356. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2357. if ui == 'w':
  2358. y -= 1
  2359. if y < 0:
  2360. y = 4
  2361. if ui == 's':
  2362. y += 1
  2363. if y > 4:
  2364. y = 0
  2365. if ui == 'a':
  2366. x -= 1
  2367. if x < 0:
  2368. x = len(char_field[1])-1
  2369. if ui == 'd':
  2370. x += 1
  2371. if x > len(char_field[1])-1:
  2372. x = 0
  2373. if ui == 'e':
  2374. if pos <= length:
  2375. string += char_field[y][x]
  2376. pos += 1
  2377. if ui == 'b':
  2378. run = False
  2379. if ui == 'x':
  2380. if pos > 0:
  2381. pos -= 1
  2382. string = string[:pos]
  2383. return string
  2384. def render_dead(self):
  2385. global exitgame
  2386. self.reset_hit_matrix()
  2387. if player.godmode == True:
  2388. player.respawn()
  2389. message.add('YOU DIE.. NOT!')
  2390. return True
  2391. run = True
  2392. while run:
  2393. if low_res == False:
  2394. s = pygame.Surface((640,360))
  2395. else:
  2396. s = pygame.Surface((320,240))
  2397. s.fill((48,48,48)) #paint it grey(to clear the screen)
  2398. text_image = screen.font.render('YOU ARE DEAD!',1,(255,255,255))
  2399. if low_res == False:
  2400. s.blit(text_image,(175,60))
  2401. else:
  2402. s.blit(text_image,(75,60))
  2403. if player.difficulty == 3: #you play on roguelike mode
  2404. choose_string = '------------- ['+key_name['x']+'] - END GAME'
  2405. else:#you play on a other mode
  2406. choose_string = '['+key_name['e']+'] - RESPAWN ['+key_name['x']+'] - END GAME'
  2407. choose_image = screen.font.render(choose_string,1,(255,255,255))
  2408. if low_res == False:
  2409. s.blit(choose_image,(125,200))
  2410. else:
  2411. s.blit(choose_image,(25,200))
  2412. if game_options.mousepad == 1 and low_res == False:
  2413. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2414. else:
  2415. s_help = pygame.Surface((160,360))
  2416. s_help.fill((48,48,48))
  2417. s.blit(s_help,(480,0))
  2418. if game_options.mousepad == 0 and low_res == False:
  2419. s_help = pygame.Surface((640,360))
  2420. s_help.fill((48,48,48))
  2421. s_help.blit(s,(80,0))
  2422. s = s_help
  2423. else:
  2424. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2425. if low_res == False:
  2426. s = pygame.transform.scale(s,(screen.displayx,screen.displayy))
  2427. screen.screen.blit(s,(0,0))
  2428. pygame.display.flip()
  2429. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2430. if ui == 'exit':
  2431. global master_loop
  2432. global playing
  2433. global exitgame
  2434. exitgame = True
  2435. if player.difficulty !=3:
  2436. screen.render_load(5)
  2437. save(world,player,time,gods,save_path,os.sep)
  2438. screen.save_tmp_png()
  2439. else:
  2440. files_to_remove = ('gods.data','player.data','world.data','time.data')
  2441. for i in files_to_remove:
  2442. del_file = save_path + os.sep + i
  2443. try:
  2444. os.remove(del_file)
  2445. except:
  2446. None
  2447. master_loop = False
  2448. playing = False
  2449. run = False
  2450. return('exit')
  2451. if ui == 'e' and player.difficulty != 3:
  2452. player.respawn()
  2453. save(world,player,time,gods,save_path,os.sep)
  2454. run = False
  2455. elif ui == 'x':
  2456. player.respawn()
  2457. if player.difficulty != 3:
  2458. screen.render_load(5)
  2459. save(world,player,time,gods,save_path,os.sep)
  2460. screen.save_tmp_png()
  2461. else:
  2462. files_to_remove = ('gods.data','player.data','world.data','time.data')
  2463. for i in files_to_remove:
  2464. del_file = save_path + os.sep + i
  2465. try:
  2466. os.remove(del_file)
  2467. except:
  2468. None
  2469. run = False
  2470. exitgame = True
  2471. class maP():
  2472. def __init__(self, name, tilemap, visit=False, map_type='overworld',monster_num=1):
  2473. self.name = name
  2474. self.known = []
  2475. self.containers = []
  2476. self.tilemap = tilemap
  2477. self.visit = visit
  2478. self.last_visit = 0 #-------test only
  2479. self.map_type = map_type
  2480. self.monster_num = monster_num
  2481. self.build_type = 'Full' #Full: build everything you want, Part: no stairs, None: Buildmode is not callable
  2482. self.thirst_multi_day = 1
  2483. self.thirst_multi_night = 1
  2484. self.no_monster_respawn = False
  2485. self.countdowns = []
  2486. self.npcs = []
  2487. self.monster_plus = 0
  2488. self.monster_count = 0
  2489. self.music_day_original = 'overworld'
  2490. self.music_day = self.music_day_original
  2491. self.music_night_original = 'night'
  2492. self.music_night = self.music_night_original
  2493. self.generation_release = release_number
  2494. for y in range (0,max_map_size):
  2495. self.known.append([])
  2496. for x in range (0,max_map_size):
  2497. self.known[y].append(0)
  2498. for y in range (0,max_map_size):
  2499. self.containers.append([])
  2500. for x in range (0,max_map_size):
  2501. self.containers[y].append(0)
  2502. for y in range (0,max_map_size):
  2503. self.npcs.append([])
  2504. for x in range (0,max_map_size):
  2505. self.npcs[y].append(0)
  2506. def fill(self, tile):
  2507. for y in range (0,max_map_size):
  2508. for x in range(0,max_map_size):
  2509. self.tilemap[y][x] = deepcopy(tile)
  2510. def check_fov(self,x,y,dist):
  2511. fov = []
  2512. startx = x-8
  2513. starty = y-6
  2514. extreme_coordinates = []
  2515. dist_coordinates = []
  2516. for yy in range(0,12):
  2517. fov.append([])
  2518. for xx in range(0,15):
  2519. fov[yy].append(0)
  2520. dist1 = ((8-xx)**2+(6-yy)**2)**0.5
  2521. if dist1 > 0:
  2522. extreme_coordinates.append((xx,yy))
  2523. dist_coordinates.append(dist1)
  2524. for i in range(0,len(extreme_coordinates)-1):
  2525. c = 0
  2526. run = True
  2527. while run:
  2528. dir_x = (8-extreme_coordinates[i][0])/dist_coordinates[i]
  2529. dir_y = (6-extreme_coordinates[i][1])/dist_coordinates[i]
  2530. lx = int(round(8+c*dir_x))
  2531. ly = int(6+c*dir_y)
  2532. if ly < 6:
  2533. ly += 1
  2534. elif ly > 6:
  2535. ly -= 1
  2536. ldist = ((8-lx)**2+(6-ly)**2)**0.5
  2537. try:
  2538. fov[ly][lx] = 1
  2539. except:
  2540. None
  2541. c+=1
  2542. if lx < 0 or lx > 14 or ly < 0 or ly > 11:
  2543. run = False
  2544. elif ldist >= dist:
  2545. run = False
  2546. elif self.tilemap[starty+ly][startx+lx].transparency == False:
  2547. run = False
  2548. return fov
  2549. def check_los(self,startx,starty,endx,endy):
  2550. 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:
  2551. return False
  2552. try:
  2553. m = (startx-endx)/(starty-endy)
  2554. except:
  2555. m = 'error'
  2556. if m != 'error':
  2557. n = starty-(m*startx)
  2558. if startx < endx:
  2559. c = 1
  2560. elif startx > endx:
  2561. c = -1
  2562. else:
  2563. return True
  2564. else:
  2565. if starty < endy:
  2566. c = 1
  2567. elif starty > endy:
  2568. c = -1
  2569. else:
  2570. return True
  2571. test = True
  2572. run=True
  2573. count = 0
  2574. while run:
  2575. if m != 'error':
  2576. x = startx + count
  2577. y = int((m*x)+n)
  2578. elif starty==endy:
  2579. x = startx
  2580. y = starty + count
  2581. try:
  2582. if self.tilemap[y][x].transparency == False and x != endx and y != endy:
  2583. test = False
  2584. if x == endx or y == endy:
  2585. run = False
  2586. count += c
  2587. except:
  2588. run = False
  2589. return test
  2590. def set_round_frame(self,tile,radius):
  2591. center = int(max_map_size/2)
  2592. for y in range(0,max_map_size):
  2593. for x in range(0,max_map_size):
  2594. range_x = x-center
  2595. range_y = y-center
  2596. if ((range_x**2+range_y**2)**0.5) > radius:
  2597. self.tilemap[y][x] = tile
  2598. def set_music(self,day,night,change_original=False):
  2599. if day != None:
  2600. self.music_day = day
  2601. if change_original == True:
  2602. self.music_day_original = day
  2603. if night != None:
  2604. self.music_night = night
  2605. if change_original == True:
  2606. self.music_night_original = night
  2607. def drunken_finder(self,startx,starty,tile):
  2608. x = startx
  2609. y = starty
  2610. run = True
  2611. while run:
  2612. direction = random.randint(0,3)
  2613. if direction == 0:
  2614. y -= 1
  2615. elif direction == 1:
  2616. x += 1
  2617. elif direction == 2:
  2618. y += 1
  2619. else:
  2620. x -= 1
  2621. if self.tilemap[y][x].techID == tile.techID:
  2622. run = False
  2623. return (x,y)
  2624. def drunken_walker(self,startx,starty,tile_replace,num_replace):
  2625. num = 1
  2626. x = startx
  2627. y = starty
  2628. self.tilemap[y][x] = tile_replace
  2629. while num < num_replace:
  2630. #step 0: get possible directions
  2631. dir_list = []
  2632. for n in range(-1,2):
  2633. if x+n < max_map_size-2 and x+n > 2:
  2634. if x+n < max_map_size-7 and x+n > 7:
  2635. count = 5
  2636. else:
  2637. count = min((max_map_size-2)-(x+n),(x+n),3)
  2638. count = max(count,1)#only to be sure count < 1
  2639. for c in range(0,count):
  2640. dir_list.append([x+n,y])
  2641. if y+n < max_map_size-2 and y+n > 2:
  2642. if y+n < max_map_size-7 and y+n > 7:
  2643. count = 5
  2644. else:
  2645. count = min((max_map_size-2)-(y+n),(y+n),3)
  2646. count = max(count,1)#only to be sure count < 1
  2647. for c in range(0,count):
  2648. dir_list.append([x,y+n])
  2649. #step 1: set tile new tile
  2650. ran = random.randint(0,len(dir_list)-1)
  2651. x = dir_list[ran][0]
  2652. y = dir_list[ran][1]
  2653. if self.tilemap[y][x].techID != tile_replace.techID:
  2654. self.tilemap[y][x] = tile_replace
  2655. num += 1
  2656. def floating(self,startx,starty,tile_fill,tile_border):
  2657. #its important to use a tile_fill that isn't on the map and a tile_border that is on the map
  2658. run = True
  2659. self.tilemap[starty][startx] = deepcopy(tile_fill)
  2660. while run:
  2661. count = 0
  2662. for y in range(0,max_map_size):
  2663. for x in range(0,max_map_size):
  2664. if self.tilemap[y][x].techID == tile_fill.techID:
  2665. for yy in range(y-1,y+2):
  2666. for xx in range(x-1,x+2):
  2667. try:
  2668. if self.tilemap[yy][xx].techID != tile_border.techID and self.tilemap[yy][xx].techID != tile_fill.techID:
  2669. self.tilemap[yy][xx] = deepcopy(tile_fill)
  2670. count += 1
  2671. except:
  2672. None
  2673. if count == 0:
  2674. run = False
  2675. def float_civilisation(self,start_x,start_y):
  2676. tm = []
  2677. for y in range(0,max_map_size):
  2678. tm.append([])
  2679. for x in range(0,max_map_size):
  2680. tm[y].append(0)
  2681. tm[start_y][start_x] = 1
  2682. run = True
  2683. total_count = 1
  2684. while run:
  2685. count = 0
  2686. for yy in range(0,max_map_size):
  2687. for xx in range(0,max_map_size):
  2688. if tm[yy][xx] == 1:
  2689. for yyy in range(yy-1,yy+2):
  2690. for xxx in range(xx-1,xx+2):
  2691. try:
  2692. if tm[yyy][xxx] == 0 and self.tilemap[yyy][xxx].move_group == 'soil' and self.tilemap[yyy][xxx].civilisation == True:
  2693. tm[yyy][xxx] = 1
  2694. count += 1
  2695. total_count += 1
  2696. elif self.tilemap[yyy][xxx].civilisation == False:
  2697. return 0
  2698. except:
  2699. None
  2700. if count == 0:
  2701. run = False
  2702. return total_count
  2703. def get_quarter_size(self,startx,starty):
  2704. #this funktion gives back a tulpel with the width and height of a quarter made out of the same tile like the start position
  2705. techID = self.tilemap[starty][startx].techID
  2706. q_width = 0
  2707. q_height = 0
  2708. run_w = True
  2709. run_h = True
  2710. while run_w:
  2711. if self.tilemap[starty][startx+q_width].techID == techID:
  2712. q_width += 1
  2713. else:
  2714. run_w = False
  2715. while run_h:
  2716. if self.tilemap[starty+q_height][startx].techID == techID:
  2717. q_height += 1
  2718. else:
  2719. run_h = False
  2720. return (q_width,q_height)
  2721. def set_frame(self,tile):
  2722. for y in range (0,max_map_size):
  2723. for x in range (0,max_map_size):
  2724. if x == 0 or x == max_map_size-1 or y == 0 or y == max_map_size-1:
  2725. self.tilemap[y][x] = tile
  2726. def cut(self, minx, maxx, miny, maxy, replace):
  2727. #everything that is not between min and mx is replaced abainst a tile
  2728. for y in range (0,max_map_size):
  2729. for x in range (0,max_map_size):
  2730. if x < minx or x > maxx or y < miny or y > maxy:
  2731. self.tilemap[y][x] = replace
  2732. def imp(self, start_x, start_y, replace_inner, replace_outer, step_min, step_max, circles, replace_except=None): #dig random caves
  2733. #was made to generate random caves but dosn't pleased me. maybe this can be used for mazes.(unused atm)
  2734. x = start_x
  2735. y = start_y
  2736. for l in range (0,circles):
  2737. run = True
  2738. while run:
  2739. direction = random.randint(0,3)
  2740. move_x = 0
  2741. move_y = 0
  2742. if direction == 0:
  2743. move_y = -1
  2744. elif direction == 1:
  2745. move_x = 1
  2746. elif direction == 2:
  2747. move_y = 1
  2748. else:
  2749. move_x= -1
  2750. length = random.randint(step_min, step_max)
  2751. for m in range (0,length):
  2752. x = x + move_x
  2753. y = y + move_y
  2754. if x <= 1 or x >= 78 or y <= 1 or y >= 78:
  2755. break
  2756. run = False
  2757. self.tilemap[y][x] = replace_inner
  2758. for b in range (-1,2):
  2759. for a in range (-1,2):
  2760. 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:
  2761. self.tilemap[y+a][x+b] = replace_outer
  2762. run = False
  2763. def imp_connect(self,xpos,ypos,replace_inner,replace_except=None,except_replacer=None,style='straight'): #conects two or more points
  2764. for a in range (0,len(ypos)-1):
  2765. for b in range(0,len(xpos)-1):
  2766. y = ypos[a]
  2767. x = xpos[b]
  2768. go = True
  2769. direction = 0 #needed for natural ways. jumps between 0 and 1
  2770. while go:
  2771. try:
  2772. y_goal = ypos[a+1]
  2773. x_goal = xpos[b+1]
  2774. except:
  2775. y_goal = ypos[0]
  2776. x_goal = xpos[0]
  2777. if x == x_goal and y == y_goal:
  2778. go = False
  2779. if x_goal - x < 0: #find out if you need to go right or left
  2780. x_direction = -1
  2781. else:
  2782. x_direction = 1
  2783. if y_goal - y < 0: #find out if you need to go up or down
  2784. y_direction = -1
  2785. else:
  2786. y_direction = 1
  2787. if style == 'straight':
  2788. if x != x_goal:
  2789. x = x + x_direction
  2790. if self.tilemap[y][x] != replace_except:
  2791. self.tilemap[y][x] = replace_inner
  2792. elif self.tilemap[y][x] == replace_except:
  2793. self.tilemap[y][x] = except_replacer
  2794. elif y != y_goal:
  2795. y = y + y_direction
  2796. if self.tilemap[y][x] != replace_except:
  2797. self.tilemap[y][x] = replace_inner
  2798. elif self.tilemap[y][x] == replace_except:
  2799. self.tilemap[y][x] = except_replacer
  2800. elif style == 'natural':
  2801. if x != x_goal and direction == 0:
  2802. x = x + x_direction
  2803. if self.tilemap[y][x] != replace_except:
  2804. self.tilemap[y][x] = replace_inner
  2805. elif self.tilemap[y][x] == replace_except:
  2806. self.tilemap[y][x] = except_replacer
  2807. elif y != y_goal and direction == 1:
  2808. y = y + y_direction
  2809. if self.tilemap[y][x] != replace_except:
  2810. self.tilemap[y][x] = replace_inner
  2811. elif self.tilemap[y][x] == replace_except:
  2812. self.tilemap[y][x] = except_replacer
  2813. if direction == 0:
  2814. direction = 1
  2815. elif direction == 1:
  2816. direction = 0
  2817. def spawn_monsters(self,depth):
  2818. #This function spawns monsters on the map
  2819. if self.map_type == 'elfish_fortress':
  2820. monster_max = 0
  2821. for y in range(0,max_map_size):
  2822. for x in range(0,max_map_size):
  2823. if self.tilemap[y][x].techID == tl.tlist['functional'][8].techID:#this is a bed
  2824. monster_max += 1
  2825. else:
  2826. monster_max = (max_map_size*max_map_size)/30
  2827. monster_max = int(monster_max * self.monster_num)
  2828. if self.map_type == 'grot':
  2829. spawnpoints = self.find_all_moveable(ignore_water = False, ignore_no_spawn = False)
  2830. else:
  2831. spawnpoints = self.find_all_moveable(ignore_no_spawn = False)
  2832. del_list = []
  2833. monster_count = self.monster_count
  2834. for i in range (0,len(spawnpoints)):
  2835. if self.npcs[spawnpoints[i][1]][spawnpoints[i][0]] != 0: #there is a monster here
  2836. spawnpoints[i] = 'del'
  2837. #monster_count += 1#count the monsters that are already on the map
  2838. newlist = []
  2839. for k in spawnpoints:
  2840. if k != 'del':
  2841. newlist.append(k)
  2842. spawnpoints = newlist
  2843. monster_max -= monster_count
  2844. if monster_max > len(spawnpoints):
  2845. monster_max = len(spawnpoints)
  2846. for k in range(0,monster_max):
  2847. ran = random.randint(0,len(ml.mlist[self.map_type])-1)
  2848. ran2 = random.randint(0,len(spawnpoints)-1)
  2849. ran3 = random.randint(0,len(ml.mlist['civilian'])-1)
  2850. 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
  2851. self.set_monster_strength(spawnpoints[ran2][0],spawnpoints[ran2][1],depth)
  2852. self.monster_count += 1
  2853. if self.no_monster_respawn == False:
  2854. self.countdowns.append(countdown('spawner',spawnpoints[ran2][1],spawnpoints[ran2][0],random.randint(5,60)))
  2855. try:
  2856. if player.difficulty == 4:
  2857. self.npcs[spawnpoints[ran2][1]][spawnpoints[ran2][0]].AI_style = 'ignore'
  2858. except:
  2859. None
  2860. #set monsters personal_id
  2861. 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))
  2862. #set monster groups
  2863. self.spawn_monster_groups(ml.mlist['kobold'][0],ml.mlist['kobold'][1],9)#kobolds
  2864. def set_monster_strength(self,x,y,z,preset_lvl=None,lvl_bonus=0):
  2865. if self.npcs[y][x] != 0:
  2866. old_lvl = self.npcs[y][x].lvl
  2867. ran = random.randint(1,3)
  2868. if Time_ready == True:
  2869. if player.difficulty == 3:
  2870. base_lvl = 25
  2871. elif player.difficulty == 2:
  2872. base_lvl = 20
  2873. elif player.difficulty == 1:
  2874. base_lvl = 15
  2875. elif player.difficulty == 0:
  2876. base_lvl = 10
  2877. else:
  2878. base_lvl = 0
  2879. time_coeff = int(base_lvl*((time.year-1)*28*12 + time.day_total)/150) #base_lvl levels each 150 days of gameplay #
  2880. else:
  2881. time_coeff = 0
  2882. 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
  2883. try:
  2884. time_coeff = player.lvl
  2885. except:
  2886. None
  2887. monster_lvl = z + ran + self.monster_plus + time_coeff
  2888. if monster_lvl >= old_lvl and old_lvl > 0:
  2889. try:
  2890. screen.write_hit_matrix(x,y,12) #render monster_lvl_up
  2891. except:
  2892. None
  2893. if preset_lvl != None:
  2894. self.npcs[y][x].lvl = preset_lvl
  2895. else:
  2896. self.npcs[y][x].lvl = monster_lvl
  2897. self.npcs[y][x].lvl += lvl_bonus
  2898. attribute_list =[]
  2899. al = ('p_strength','p_defense','m_strength','m_defense','health')
  2900. for c in range(0,5):
  2901. if self.npcs[y][x].attribute_prev[c] > 0:
  2902. for h in range(0,self.npcs[y][x].attribute_prev[c]):
  2903. attribute_list.append(al[c])
  2904. for i in range(0,self.npcs[y][x].lvl):
  2905. choice = attribute_list[random.randint(0,len(attribute_list)-1)]
  2906. if choice == 'p_strength':
  2907. self.npcs[y][x].basic_attribute.p_strength +=3
  2908. elif choice == 'p_defense':
  2909. self.npcs[y][x].basic_attribute.p_defense +=3
  2910. elif choice == 'm_strength':
  2911. self.npcs[y][x].basic_attribute.m_strength +=3
  2912. elif choice == 'm_defense':
  2913. self.npcs[y][x].basic_attribute.m_defense +=3
  2914. elif choice == 'health':
  2915. self.npcs[y][x].basic_attribute.max_lp +=1
  2916. self.npcs[y][x].lp = self.npcs[y][x].basic_attribute.max_lp
  2917. if old_lvl == 0:
  2918. el = [['spear','sword','axe','hammer'],['rune','wand','rune staff','artefact'],['armor','armor'],['necklace','amulet','talisman'],['ring','ring']]
  2919. e_nr = 0
  2920. for q in range(0,len(el)-1):
  2921. ran = random.randint(0,len(el[q])-1)
  2922. if self.npcs[y][x].worn_equipment[q] == 1:
  2923. help_equipment = item_wear(el[q][ran],random.randint(0,min((z*3),21)),random.randint(-2,2))
  2924. self.npcs[y][x].basic_attribute.p_strength += help_equipment.attribute.p_strength
  2925. self.npcs[y][x].basic_attribute.p_defense += help_equipment.attribute.p_defense
  2926. self.npcs[y][x].basic_attribute.m_strength += help_equipment.attribute.m_strength
  2927. self.npcs[y][x].basic_attribute.m_defense += help_equipment.attribute.m_defense
  2928. self.npcs[y][x].basic_attribute.luck += help_equipment.attribute.luck
  2929. def make_vault(self,on_tile,depth):
  2930. run = True
  2931. while run:
  2932. pos = self.find_any(on_tile)
  2933. test = True
  2934. orientation = random.randint(0,3)#0:north, 1:east, 2:south, 3:west
  2935. try:
  2936. if pos[0] < 6 or pos[0] > max_map_size-6 or pos[1] < 6 or pos[1] > max_map_size-6:
  2937. test = False
  2938. if orientation == 0:
  2939. x_offset = -2
  2940. y_offset = random.randint(-1,1)
  2941. elif orientation == 1:
  2942. x_offset = random.randint(-1,1)
  2943. y_offset = -2
  2944. elif orientation == 2:
  2945. x_offset = 2
  2946. y_offste = random.randint(-1,1)
  2947. else:
  2948. x_offset = random.randint(-1,1)
  2949. y_offset = 2
  2950. for ty in range(pos[1]+y_offset-1,pos[1]+y_offset+6):
  2951. for tx in range(pos[0]+x_offset-1,pos[0]+x_offset+6):
  2952. if self.tilemap[ty][tx].techID == tl.tlist['dungeon'][0].techID:
  2953. test = False
  2954. elif self.tilemap[ty][tx].techID == tl.tlist['dungeon'][6].techID:
  2955. test = False
  2956. elif self.tilemap[ty][tx].techID == tl.tlist['dungeon'][9].techID:
  2957. test = False
  2958. elif self.tilemap[ty][tx].techID == tl.tlist['functional'][2].techID:
  2959. test = False
  2960. except:
  2961. test = False
  2962. if test:
  2963. run = False
  2964. for yy in range(pos[1]+y_offset-2,pos[1]+y_offset+3):
  2965. for xx in range(pos[0]+x_offset-2,pos[0]+x_offset+3):
  2966. 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:
  2967. self.tilemap[yy][xx] = deepcopy(tl.tlist['dungeon'][9])
  2968. self.tilemap[yy][xx].no_spawn = True
  2969. else:
  2970. self.tilemap[yy][xx] = deepcopy(tl.tlist['dungeon'][0])
  2971. self.tilemap[yy][xx].no_spawn = True
  2972. make_loot = True # if make_loot is set on False no gems or ore will spawn inside the vault
  2973. vault_center_x = pos[0]+x_offset
  2974. vault_center_y = pos[1]+y_offset
  2975. door_pos = self.drunken_finder(vault_center_x,vault_center_y,tl.tlist['dungeon'][9])
  2976. self.tilemap[door_pos[1]][door_pos[0]] = deepcopy(tl.tlist['dungeon'][6])
  2977. self.tilemap[door_pos[1]][door_pos[0]].no_spawn = True
  2978. vault_type = random.randint(0,4)
  2979. #vault_type = 4
  2980. if vault_type == 0: #Libary
  2981. replace = self.tilemap[vault_center_y][vault_center_x]
  2982. self.tilemap[vault_center_y][vault_center_x] = deepcopy(tl.tlist['functional'][19])#set a bookshelf
  2983. self.tilemap[vault_center_y][vault_center_x].replace = replace
  2984. self.tilemap[vault_center_y][vault_center_x].no_spawn = True
  2985. replace = self.tilemap[vault_center_y+1][vault_center_x]
  2986. self.tilemap[vault_center_y+1][vault_center_x] = deepcopy(tl.tlist['functional'][4])#set a chest
  2987. self.tilemap[vault_center_y+1][vault_center_x].replace = replace
  2988. self.tilemap[vault_center_y+1][vault_center_x].no_spawn = True
  2989. num_spellbooks = random.randint(2,3)#fill the chest
  2990. spellbook_list = []
  2991. 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])
  2992. for i in range(0,num_spellbooks):
  2993. ran = random.randint(0,len(sb)-1)
  2994. spellbook_list.append(sb[ran])
  2995. self.containers[vault_center_y+1][vault_center_x] = container(spellbook_list)
  2996. self.npcs[vault_center_y-1][vault_center_x-1] = deepcopy(ml.mlist['grot'][0]) #
  2997. self.set_monster_strength(vault_center_x-1,vault_center_y-1,depth,lvl_bonus=3) #
  2998. self.npcs[vault_center_y-1][vault_center_x+1] = deepcopy(ml.mlist['grot'][0]) #
  2999. self.set_monster_strength(vault_center_x+1,vault_center_y-1,depth,lvl_bonus=3) #set blue nagas
  3000. self.npcs[vault_center_y+1][vault_center_x-1] = deepcopy(ml.mlist['grot'][0]) #
  3001. self.set_monster_strength(vault_center_x-1,vault_center_y+1,depth,lvl_bonus=3) #
  3002. self.npcs[vault_center_y+1][vault_center_x+1] = deepcopy(ml.mlist['grot'][0]) #
  3003. self.set_monster_strength(vault_center_x+1,vault_center_y+1,depth,lvl_bonus=3) #
  3004. if vault_type == 1: #Slime pit
  3005. replace = self.tilemap[vault_center_y][vault_center_x]
  3006. self.tilemap[vault_center_y][vault_center_x] = deepcopy(tl.tlist['statue'][2])#set a blob statue
  3007. self.tilemap[vault_center_y][vault_center_x].replace = replace
  3008. self.tilemap[vault_center_y][vault_center_x].no_spawn = True
  3009. self.npcs[vault_center_y-1][vault_center_x-1] = deepcopy(ml.mlist['special'][10]) #
  3010. self.set_monster_strength(vault_center_x-1,vault_center_y-1,depth,lvl_bonus=3) #
  3011. self.npcs[vault_center_y-1][vault_center_x+1] = deepcopy(ml.mlist['special'][10]) #
  3012. self.set_monster_strength(vault_center_x+1,vault_center_y-1,depth,lvl_bonus=3) #set giant blobs
  3013. self.npcs[vault_center_y+1][vault_center_x-1] = deepcopy(ml.mlist['special'][10]) #
  3014. self.set_monster_strength(vault_center_x-1,vault_center_y+1,depth,lvl_bonus=3) #
  3015. self.npcs[vault_center_y+1][vault_center_x+1] = deepcopy(ml.mlist['special'][10]) #
  3016. self.set_monster_strength(vault_center_x+1,vault_center_y+1,depth,lvl_bonus=3) #
  3017. if vault_type == 2: #Kobold Lair
  3018. replace = self.tilemap[vault_center_y][vault_center_x]
  3019. self.tilemap[vault_center_y][vault_center_x] = deepcopy(tl.tlist['deco'][9])#set a stony throne
  3020. self.tilemap[vault_center_y][vault_center_x].replace = replace #
  3021. self.tilemap[vault_center_y][vault_center_x].no_spawn = True #
  3022. for posy in range(vault_center_y-1,vault_center_y+2): #
  3023. for posx in range(vault_center_x-1,vault_center_x+2): #set Kobolds
  3024. self.npcs[posy][posx] = deepcopy(ml.mlist['kobold'][1]) #
  3025. self.set_monster_strength(posx,posy,depth,lvl_bonus=3) #
  3026. self.npcs[vault_center_y][vault_center_x] = deepcopy(ml.mlist['kobold'][0]) #set kobold shaman
  3027. self.set_monster_strength(vault_center_x,vault_center_y,depth,lvl_bonus=3) #
  3028. if vault_type == 3: #Bat Cave
  3029. make_loot = False
  3030. for posy in range(vault_center_y-1,vault_center_y+2): #
  3031. for posx in range(vault_center_x-1,vault_center_x+2): #set bats
  3032. self.npcs[posy][posx] = deepcopy(ml.mlist['cave'][2]) #
  3033. self.set_monster_strength(posx,posy,depth) #
  3034. if vault_type == 4: #mimic chamber
  3035. make_loot = False
  3036. ranx = random.randint(-1,1) #
  3037. rany = random.randint(-1,1) #
  3038. replace = self.tilemap[vault_center_y+rany][vault_center_x+ranx] #
  3039. self.tilemap[vault_center_y+rany][vault_center_x+ranx] = deepcopy(tl.tlist['functional'][4])#set a chest
  3040. self.tilemap[vault_center_y+rany][vault_center_x+ranx].replace = replace #
  3041. self.tilemap[vault_center_y+rany][vault_center_x+ranx].no_spawn = True #
  3042. 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])
  3043. ransb = random.randint(0,len(sb)-1)
  3044. book = sb[ransb]
  3045. pick = item_wear('pickaxe', 20,0)
  3046. axe = item_wear('axe',20,0)
  3047. self.containers[vault_center_y+rany][vault_center_x+ranx] = container([book,axe,pick])#fill chest
  3048. for posy in range(vault_center_y-1,vault_center_y+2): #
  3049. for posx in range(vault_center_x-1,vault_center_x+2): #set sleeping mimics
  3050. if self.tilemap[posy][posx].techID != tl.tlist['functional'][4].techID: #
  3051. self.npcs[posy][posx] = deepcopy(ml.mlist['special'][3]) #
  3052. if make_loot == True:
  3053. for yyy in range(vault_center_y-2,vault_center_y+3):
  3054. for xxx in range(vault_center_x-2,vault_center_x+3):
  3055. if self.tilemap[yyy][xxx].techID == tl.tlist['dungeon'][0].techID:
  3056. ran2 = random.randint(0,2)
  3057. replace = self.tilemap[yyy][xxx]
  3058. if ran2 > 1:
  3059. self.tilemap[yyy][xxx] = deepcopy(tl.tlist['misc'][9])#set gem
  3060. self.tilemap[yyy][xxx].no_spawn = True
  3061. else:
  3062. self.tilemap[yyy][xxx] = deepcopy(tl.tlist['misc'][11])#set ore
  3063. self.tilemap[yyy][xxx].no_spawn = True
  3064. self.tilemap[yyy][xxx].replace = replace
  3065. #print('Made vault at: '+str(pos[0])+','+str(pos[1])+' Type:'+str(vault_type))
  3066. ####go on here
  3067. def make_orc_cave(self,on_tile):
  3068. run = True
  3069. while run:
  3070. pos = self.find_any(on_tile)
  3071. test = True
  3072. try:
  3073. for ty in range(pos[1]-2,pos[1]+3):
  3074. for tx in range(pos[0]-2,pos[0]+3):
  3075. if self.tilemap[ty][tx].techID == tl.tlist['misc'][16]:
  3076. test = False
  3077. elif self.tilemap[ty][tx].techID == tl.tlist['mine'][0]:
  3078. test = False
  3079. elif self.tilemap[ty][tx].techID == tl.tlist['dungeon'][3]:
  3080. test = False
  3081. elif self.tilemap[ty][tx].techID == tl.tlist['misc'][12]:
  3082. test = False
  3083. except:
  3084. test = False
  3085. if ((pos[0]-(max_map_size/2))**2+(pos[1]-(max_map_size/2))**2)**0.5 > 10:
  3086. 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:
  3087. run = False
  3088. for y in range(pos[1]-2,pos[1]+3):
  3089. for x in range(pos[0]-2,pos[0]+3):
  3090. self.tilemap[y][x] = tl.tlist['misc'][16] #fill with solid orcish wall
  3091. for y in range(pos[1]-1,pos[1]+2):
  3092. for x in range(pos[0]-1,pos[0]+2):
  3093. self.tilemap[y][x] = tl.tlist['mine'][0] #fill inner with orcish mine floor
  3094. if x != pos[0] or y != pos[1]:
  3095. self.npcs[y][x] = deepcopy(ml.mlist['orc'][random.randint(0,len(ml.mlist['orc'])-1)]) #
  3096. else: #
  3097. self.npcs[y][x] = deepcopy(ml.mlist['orcish_mines'][1]) #
  3098. self.set_monster_strength(x,y,1) #generate orcs
  3099. self.countdowns.append(countdown('orc_spawner',x,y,random.randint(5,60))) #
  3100. self.tilemap[pos[1]-2][pos[0]] = deepcopy(tl.tlist['dungeon'][3])#
  3101. self.tilemap[pos[1]+2][pos[0]] = deepcopy(tl.tlist['dungeon'][3])# make dungeon doors
  3102. self.tilemap[pos[1]][pos[0]-2] = deepcopy(tl.tlist['dungeon'][3])#
  3103. self.tilemap[pos[1]][pos[0]+2] = deepcopy(tl.tlist['dungeon'][3])#
  3104. self.tilemap[pos[1]-2][pos[0]-2] = deepcopy(tl.tlist['misc'][12])#
  3105. self.tilemap[pos[1]-2][pos[0]-2].replace = deepcopy(on_tile) #
  3106. self.tilemap[pos[1]-2][pos[0]+2] = deepcopy(tl.tlist['misc'][12])#
  3107. self.tilemap[pos[1]-2][pos[0]+2].replace = deepcopy(on_tile) # add orc deko to the connors
  3108. self.tilemap[pos[1]+2][pos[0]-2] = deepcopy(tl.tlist['misc'][12])#
  3109. self.tilemap[pos[1]+2][pos[0]-2].replace = deepcopy(on_tile) #
  3110. self.tilemap[pos[1]+2][pos[0]+2] = deepcopy(tl.tlist['misc'][12])#
  3111. self.tilemap[pos[1]+2][pos[0]+2].replace = deepcopy(on_tile) #
  3112. self.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['misc'][18])#set a crystal orb
  3113. def AI_move(self):
  3114. #This function moves all monsters that are 7 or less fields away from the player.
  3115. #It dosn't move all monsters to save performance
  3116. ymin = player.pos[1]-7
  3117. if ymin < 0:
  3118. ymin = 0
  3119. xmin = player.pos[0]-7
  3120. if xmin < 0:
  3121. xmin = 0
  3122. ymax = player.pos[1]+8
  3123. if ymax > max_map_size:
  3124. ymax = max_map_size
  3125. xmax = player.pos[0]+8
  3126. if xmax > max_map_size:
  3127. xmax = max_map_size
  3128. for y in range (ymin,ymax):#reset the move_done switches
  3129. for x in range (xmin,xmax):
  3130. if self.npcs[y][x] != 0:
  3131. if self.npcs[y][x].lp > 0:
  3132. self.npcs[y][x].move_done = 0
  3133. else:
  3134. test = False
  3135. while test == False:
  3136. test = self.monster_die(x,y)
  3137. for y in range (ymin,ymax):
  3138. for x in range (xmin,xmax):
  3139. if self.npcs[y][x] != 0 and self.npcs[y][x].move_done == 0:#if there is a monster at this place
  3140. #I. Get possible fields for a move
  3141. moves = [(x,y)]
  3142. yy = (-1,0,0,1)
  3143. xx = (0,-1,1,0)
  3144. for i in range (0,4):
  3145. try:
  3146. monster_move_groups = self.npcs[y][x].move_groups
  3147. tile_move_group = self.tilemap[y+yy[i]][x+xx[i]].move_group
  3148. move_group_check = tile_move_group in monster_move_groups
  3149. if self.npcs[y+yy[i]][x+xx[i]] == 0:
  3150. npc = False
  3151. else:
  3152. npc = True
  3153. 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
  3154. stair = True
  3155. else:
  3156. stair = False
  3157. if x + xx[i] == player.pos[0] and y + yy[i] == player.pos[1]:
  3158. playerpos = True
  3159. else:
  3160. playerpos = False
  3161. if move_group_check == True and npc == False and stair == False and playerpos == False:
  3162. moves.append((x+xx[i],y+yy[i]))
  3163. except:
  3164. print('Debug:Error')
  3165. #II. Find out which possible move leads to which distance between monster and player
  3166. distances = []
  3167. for j in range (0,len(moves)):
  3168. a = player.pos[0] - moves[j][0]
  3169. b = player.pos[1] - moves[j][1]
  3170. c = (a**2 + b**2)**0.5 # this is just the good old pythagoras (c² = a² + b²)
  3171. distances.append(c)
  3172. #III. Choose the right move (or special action)
  3173. do_move = 'foo'
  3174. if self.npcs[y][x].AI_style == 'hostile':
  3175. if self.npcs[y][x].lp < self.npcs[y][x].basic_attribute.max_lp and player.lp > 2 and self.npcs[y][x].num_special > 0 :#this is a defensive situation for the monster
  3176. ran = random.randint(0,99)
  3177. if ran < self.npcs[y][x].def_teleport and self.npcs[y][x].move_done != 1:
  3178. moves = self.find_all_moveable(ignore_player_pos = False)
  3179. if moves != False:
  3180. if len(moves) == 1:
  3181. pos_num = 0
  3182. else:
  3183. pos_num = random.randint(0,len(moves)-1)
  3184. self.npcs[y][x].move_done = 1
  3185. self.npcs[y][x].num_special -= 1
  3186. tp_string = 'A ' + self.npcs[y][x].name + ' teleports.'
  3187. message.add(tp_string)
  3188. screen.write_hit_matrix(x,y,7)
  3189. sfx.play('teleport')
  3190. self.npcs[moves[pos_num][1]][moves[pos_num][0]] = self.npcs[y][x]
  3191. self.npcs[y][x] = 0
  3192. ran = random.randint(0,99)
  3193. if self.npcs[y][x] != 0:
  3194. if ran < self.npcs[y][x].def_flee and self.npcs[y][x].move_done != 1 and self.npcs[y][x].lp < self.npcs[y][x].basic_attribute.max_lp:
  3195. flee_string = 'A ' + self.npcs[y][x].name + ' turns to flee.'
  3196. message.add(flee_string)
  3197. self.npcs[y][x].AI_style = 'flee'
  3198. self.npcs[y][x].move_done = 1
  3199. self.npcs[y][x].num_special -= 1
  3200. ran = random.randint(0,99)
  3201. if ran < self.npcs[y][x].def_potion and self.npcs[y][x].move_done != 1:
  3202. if self.npcs[y][x].lp < self.npcs[y][x].basic_attribute.max_lp:
  3203. potion_string = 'A ' + self.npcs[y][x].name + ' quaffes a potion of healing.'
  3204. message.add(potion_string)
  3205. screen.write_hit_matrix(x,y,6)
  3206. lp = min(self.npcs[y][x].basic_attribute.max_lp, self.npcs[y][x].lp+7)
  3207. self.npcs[y][x].lp = lp
  3208. sfx.play('drink')
  3209. self.npcs[y][x].move_done = 1
  3210. self.npcs[y][x].num_special -= 1
  3211. if self.npcs[y][x] != 0:
  3212. if distances[0] > 1 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
  3213. ran = random.randint(0,99)
  3214. if ran < self.npcs[y][x].spawn_skeleton or ran < self.npcs[y][x].spawn_shadow or ran < self.npcs[y][x].spawn_spider or ran < self.npcs[y][x].spawn_crow:
  3215. coin = random.randint(0,1)
  3216. xlist = []
  3217. ylist = []
  3218. for yy in range(y-1,y+2):
  3219. for xx in range(x-1,x+2):
  3220. if self.tilemap[yy][xx].move_group == 'soil' and self.npcs[yy][xx] == 0:
  3221. xlist.append(xx)
  3222. ylist.append(yy)
  3223. if len(xlist) == len(ylist) and len(xlist) > 0:
  3224. if len(xlist) > 1:
  3225. num = random.randint(0,len(xlist)-1)
  3226. else:
  3227. num = 0
  3228. if self.npcs[y][x].spawn_skeleton > 0 and self.npcs[y][x].move_done != 1 and self.npcs[y][x].num_special > 0:
  3229. self.npcs[ylist[num]][xlist[num]] = deepcopy(ml.mlist['special'][7])
  3230. self.npcs[ylist[num]][xlist[num]].personal_id = self.npcs[y][x].personal_id + '_child'
  3231. self.set_monster_strength(xlist[num],ylist[num],player.pos[2])
  3232. mes = 'A ' + self.npcs[y][x].name + ' summons a skeleton.'
  3233. message.add(mes)
  3234. sfx.play('teleport')
  3235. screen.write_hit_matrix(xlist[num],ylist[num],7)
  3236. self.npcs[y][x].move_done = 1
  3237. self.npcs[y][x].num_special -= 1
  3238. if self.npcs[y][x].spawn_shadow > 0 and self.npcs[y][x].move_done != 1 and self.npcs[y][x].num_special > 0:
  3239. self.npcs[ylist[num]][xlist[num]] = deepcopy(ml.mlist['special'][8])
  3240. self.npcs[ylist[num]][xlist[num]].personal_id = self.npcs[y][x].personal_id + '_child'
  3241. self.set_monster_strength(xlist[num],ylist[num],player.pos[2])
  3242. mes = 'A ' + self.npcs[y][x].name + ' summons a shadow.'
  3243. message.add(mes)
  3244. sfx.play('teleport')
  3245. screen.write_hit_matrix(xlist[num],ylist[num],7)
  3246. self.npcs[y][x].move_done = 1
  3247. self.npcs[y][x].num_special -= 1
  3248. if self.npcs[y][x].spawn_crow > 0 and self.npcs[y][x].move_done != 1 and self.npcs[y][x].num_special > 0 and coin == 0:
  3249. self.npcs[ylist[num]][xlist[num]] = deepcopy(ml.mlist['special'][12])
  3250. self.npcs[ylist[num]][xlist[num]].personal_id = self.npcs[y][x].personal_id + '_child'
  3251. self.set_monster_strength(xlist[num],ylist[num],player.pos[2])
  3252. mes = 'A ' + self.npcs[y][x].name + ' summons a crow.'
  3253. message.add(mes)
  3254. sfx.play('teleport')
  3255. screen.write_hit_matrix(xlist[num],ylist[num],7)
  3256. self.npcs[y][x].move_done = 1
  3257. self.npcs[y][x].num_special -= 1
  3258. if self.npcs[y][x].spawn_spider > 0 and self.npcs[y][x].move_done != 1 and self.npcs[y][x].num_special > 0:
  3259. self.npcs[ylist[num]][xlist[num]] = deepcopy(ml.mlist['special'][13])
  3260. self.npcs[ylist[num]][xlist[num]].personal_id = self.npcs[y][x].personal_id + '_child'
  3261. self.set_monster_strength(xlist[num],ylist[num],player.pos[2])
  3262. mes = 'A ' + self.npcs[y][x].name + ' summons a spider.'
  3263. message.add(mes)
  3264. sfx.play('teleport')
  3265. screen.write_hit_matrix(xlist[num],ylist[num],7)
  3266. self.npcs[y][x].move_done = 1
  3267. self.npcs[y][x].num_special -= 1
  3268. elif ran < self.npcs[y][x].blink and self.npcs[y][x].move_done != 1 and self.npcs[y][x].num_special > 0:
  3269. xlist = []
  3270. ylist = []
  3271. for yy in range(player.pos[1]-3,player.pos[1]+4):
  3272. for xx in range(player.pos[0]-3,player.pos[0]+4):
  3273. if self.tilemap[yy][xx].move_group in self.npcs[y][x].move_groups and self.npcs[yy][xx] == 0:
  3274. if yy != player.pos[1] or xx != player.pos[0]:
  3275. xlist.append(xx)
  3276. ylist.append(yy)
  3277. if len(xlist) != 0:
  3278. try:
  3279. rand = random.randint(0,len(xlist)-1)
  3280. except:
  3281. rand = 0
  3282. screen.write_hit_matrix(x,y,7)
  3283. screen.write_hit_matrix(xlist[rand],ylist[rand],7)
  3284. mes = 'A '+self.npcs[y][x].name+' blinks!'
  3285. message.add(mes)
  3286. self.npcs[ylist[rand]][xlist[rand]] = self.npcs[y][x]
  3287. self.npcs[y][x] = 0
  3288. self.npcs[ylist[rand]][xlist[rand]].num_special -= 1
  3289. self.npcs[ylist[rand]][xlist[rand]].move_done = 1
  3290. if x == player.pos[0] or y == player.pos[1]:
  3291. straight_line = True
  3292. else:
  3293. straight_line = False
  3294. if self.npcs[y][x] != 0 and straight_line == True and (self.npcs[y][x].range_shoot != 0 or self.npcs[y][x].range_throw_stone !=0 or self.npcs[y][x].range_throw_dart !=0 or self.npcs[y][x].range_throw_knife !=0) and distances[0] < 5:
  3295. #Step 0: Random
  3296. ran = random.randint(0,99)
  3297. if (ran < self.npcs[y][x].range_shoot or ran < self.npcs[y][x].range_throw_stone or ran < self.npcs[y][x].range_throw_dart or ran < self.npcs[y][x].range_throw_knife) and self.npcs[y][x].num_special > 0 and self.npcs[y][x].move_done != 1:
  3298. #Step 1: find the right direction
  3299. if y > player.pos[1]:
  3300. y_dir = -1
  3301. elif y < player.pos[1]:
  3302. y_dir = 1
  3303. else:
  3304. y_dir = 0
  3305. if x > player.pos[0]:
  3306. x_dir = -1
  3307. elif x < player.pos[0]:
  3308. x_dir = 1
  3309. else:
  3310. x_dir = 0
  3311. #Step 2: Check for borders
  3312. run = True
  3313. count = 1
  3314. fire_free = True
  3315. while run:
  3316. cx = x + (count*x_dir)
  3317. cy = y + (count*y_dir)
  3318. if self.tilemap[cy][cx].transparency == False:
  3319. fire_free = False
  3320. run = False
  3321. count +=1
  3322. if cx == player.pos[0] and cy == player.pos[1]:
  3323. run = False
  3324. #Step 3: Fire!
  3325. if fire_free == True:
  3326. run = True
  3327. count = 1
  3328. if self.npcs[y][x].range_shoot > 0:
  3329. sfx.play('fire')
  3330. else:
  3331. sfx.play('miss')
  3332. while run:
  3333. xx = x + (count*x_dir)
  3334. yy = y + (count*y_dir)
  3335. if xx != player.pos[0] or yy != player.pos[1]:
  3336. screen.write_hit_matrix(xx,yy,2)
  3337. if self.tilemap[yy][xx].transparency == False:
  3338. screen.write_hit_matrix(player.pos[0],player.pos[1],3)
  3339. if (self.npcs[y][x].range_shoot != 0 or self.npcs[y][x].range_throw_stone !=0 or self.npcs[y][x].range_throw_dart !=0 or self.npcs[y][x].range_throw_knife !=0):
  3340. sfx.play('throw')
  3341. run = False
  3342. else:
  3343. if self.npcs[y][x].range_shoot > 0:
  3344. self.npcs[y][x].move_done = 1
  3345. player.monster_attacks(x,y)
  3346. elif self.npcs[y][x].range_throw_stone > 0:
  3347. self.npcs[y][x].move_done = 1
  3348. message.add('A '+self.npcs[y][x].name+' throws a stone!')
  3349. chance = 9 - count
  3350. coin = random.randint(0,9)
  3351. if coin < chance:
  3352. sfx.play('hit')
  3353. screen.write_hit_matrix(player.pos[0],player.pos[1],4)
  3354. message.add('The stone hits you.(1 damage)')
  3355. player.lp -= 1
  3356. else:
  3357. sfx.play('throw')
  3358. screen.write_hit_matrix(player.pos[0],player.pos[1],3)
  3359. message.add('The stone misses you.')
  3360. elif self.npcs[y][x].range_throw_dart > 0:
  3361. self.npcs[y][x].move_done = 1
  3362. message.add('A '+self.npcs[y][x].name+' throws a dart!')
  3363. chance = 9 - count
  3364. coin = random.randint(0,9)
  3365. if coin < chance:
  3366. sfx.play('hit')
  3367. screen.write_hit_matrix(player.pos[0],player.pos[1],4)
  3368. message.add('The dart hits you.(2 damage)')
  3369. player.lp -= 2
  3370. else:
  3371. sfx.play('throw')
  3372. screen.write_hit_matrix(player.pos[0],player.pos[1],3)
  3373. message.add('The dart misses you.')
  3374. elif self.npcs[y][x].range_throw_knife > 0:
  3375. self.npcs[y][x].move_done = 1
  3376. message.add('A '+self.npcs[y][x].name+' throws a throwing knife')
  3377. chance = 9 - count
  3378. coin = random.randint(0,9)
  3379. if coin < chance:
  3380. sfx.play('hit')
  3381. screen.write_hit_matrix(player.pos[0],player.pos[1],4)
  3382. message.add('The throwing knife hits you.(3 damage)')
  3383. player.lp -= 3
  3384. else:
  3385. sfx.play('throw')
  3386. screen.write_hit_matrix(player.pos[0],player.pos[1],3)
  3387. message.add('The throwing knife misses you.')
  3388. run = False
  3389. count += 1
  3390. self.npcs[y][x].move_done = 1
  3391. if (self.npcs[y][x].range_throw_stone !=0 or self.npcs[y][x].range_throw_dart !=0 or self.npcs[y][x].range_throw_knife !=0):
  3392. self.npcs[y][x].num_special -= 1
  3393. if self.npcs[y][x] != 0 and self.npcs[y][x].move_done == 0:
  3394. if len(moves) > 0:#if no move is possible at least the 'move' of stay still must remain
  3395. good_moves = []
  3396. for k in range (0, len(moves)):
  3397. if distances[k] < distances[0]:#if the possible move makes the distance between player and monster smaller
  3398. good_moves.append(moves[k])
  3399. else:
  3400. good_moves = moves
  3401. if len(good_moves) == 0:
  3402. good_moves = moves
  3403. if len(good_moves) > 1:
  3404. ran = random.randint(0,len(good_moves)-1)
  3405. else:
  3406. ran = 0
  3407. do_move = good_moves[ran]
  3408. else:
  3409. if self.npcs[y][x].move_done == 0:
  3410. #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.
  3411. if player.inventory.materials.gem > 0:
  3412. ran = random.randint(0,99)
  3413. if ran < self.npcs[y][x].close_steal:
  3414. player.inventory.materials.gem -= 1
  3415. self.npcs[y][x].corps_lvl += 1
  3416. screen.write_hit_matrix(player.pos[0],player.pos[1],8)
  3417. screen.write_hit_matrix(x,y,9)
  3418. sfx.play('steal')
  3419. steal_string = 'A ' + self.npcs[y][x].name + ' steals a gem from you.'
  3420. message.add(steal_string)
  3421. self.npcs[y][x].move_done = 1#set the move_done switch on
  3422. if self.npcs[y][x].move_done == 0:
  3423. #casting flames
  3424. ran = random.randint(0,99)
  3425. if ran < self.npcs[y][x].close_flame and self.npcs[y][x].num_special > 0:
  3426. #Step 0: Check if any (other) monsters are near by
  3427. sfx.play('flame')
  3428. monster_num = 0
  3429. for yy in range(y-1,y+2):
  3430. for xx in range(x-1,x+2):
  3431. if self.npcs[yy][xx] != 0:
  3432. monster_num += 1
  3433. if monster_num == 1:#there is no other monster near by
  3434. num_flames = 0
  3435. for yyy in range(y-1,y+2):
  3436. for xxx in range(x-1,x+2):
  3437. if xxx != x or yyy != y:
  3438. 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':
  3439. replace = self.tilemap[yyy][xxx]
  3440. self.tilemap[yyy][xxx] = deepcopy(tl.tlist['effect'][4])
  3441. self.tilemap[yyy][xxx].replace = replace
  3442. self.countdowns.append(countdown('flame',xxx,yyy,3))
  3443. num_flames+=1
  3444. if num_flames > 0:
  3445. flame_string = 'A '+ self.npcs[y][x].name + ' casts a flame spell!'
  3446. message.add(flame_string)
  3447. self.npcs[y][x].num_special -= 1
  3448. self.npcs[y][x].move_done = 1
  3449. if self.npcs[y][x].move_done == 0 and self.npcs[y][x].num_special > 0:
  3450. #vampirism
  3451. ran = random.randint(0,99)
  3452. if ran < self.npcs[y][x].close_vampirism:
  3453. player.lp -= 1
  3454. self.npcs[y][x].lp += 1
  3455. screen.write_hit_matrix(player.pos[0],player.pos[1],18)
  3456. screen.write_hit_matrix(x,y,19)
  3457. sfx.play('vampire')
  3458. vamp_string = 'A ' + self.npcs[y][x].name +' sucks your blood.'
  3459. message.add(vamp_string)
  3460. self.npcs[y][x].num_special -= 1
  3461. self.npcs[y][x].move_done = 1
  3462. if self.npcs[y][x].move_done == 0 and self.npcs[y][x].num_special > 0:
  3463. #steal items
  3464. ran = random.randint(0,99)
  3465. if ran < self.npcs[y][x].close_stealItem:
  3466. #0: Find parent
  3467. parent_pos = False
  3468. parent_id = self.npcs[y][x].personal_id.replace('_child','')
  3469. for yy in range(0,max_map_size):
  3470. for xx in range(0,max_map_size):
  3471. if self.npcs[yy][xx] != 0 and self.npcs[yy][xx].personal_id == parent_id:
  3472. parent_pos = (xx,yy)
  3473. if parent_pos != False:
  3474. if len(self.containers[parent_pos[1]][parent_pos[0]].items) < 7:
  3475. p_check = True
  3476. else:
  3477. p_check = False
  3478. if p_check == True:
  3479. all_bp = ('Head','Body','Legs','Feet','Hold(R)','Hold(L)','Neck','Axe','Pickaxe','Hand')
  3480. final_bp = ['None',]
  3481. for i in range(0,len(all_bp)-1):
  3482. if player.inventory.wearing[all_bp[i]] != player.inventory.nothing:
  3483. final_bp.append(all_bp[i])
  3484. del final_bp[0]
  3485. if len(final_bp) > 0:
  3486. if len(final_bp) == 1:
  3487. ran = 0
  3488. else:
  3489. ran = random.randint(0,len(final_bp)-1)
  3490. item = player.inventory.wearing[final_bp[ran]]
  3491. player.inventory.wearing[final_bp[ran]] = player.inventory.nothing
  3492. self.containers[parent_pos[1]][parent_pos[0]].items.append(item)
  3493. mes = 'A '+self.npcs[y][x].name+' steals your '+item.name+'!'
  3494. message.add(mes)
  3495. sfx.play('steal')
  3496. screen.write_hit_matrix(player.pos[0],player.pos[1],21)
  3497. screen.write_hit_matrix(parent_pos[0],parent_pos[1],22)
  3498. self.npcs[y][x].lp = 0
  3499. if self.npcs[y][x].move_done == 0 and self.npcs[y][x].num_special > 0:
  3500. #throw explosives
  3501. ran = random.randint(0,99)
  3502. if ran < self.npcs[y][x].close_throwExplosive:
  3503. positions = []
  3504. for yy in range(player.pos[1]-1,player.pos[1]+2):
  3505. for xx in range(player.pos[0]-1,player.pos[0]+2):
  3506. if self.tilemap[yy][xx].replace == None and self.tilemap[yy][xx].move_group == 'soil' and self.tilemap[yy][xx].use_group == 'None':
  3507. positions.append((xx,yy))
  3508. if len(positions) > 0:
  3509. sfx.play('throw')
  3510. screen.write_hit_matrix(x,y,20)
  3511. ran = random.randint(0,len(positions)-1)
  3512. pos = positions[ran]
  3513. screen.write_hit_matrix(pos[0],pos[1],16)
  3514. coin = random.randint(0,3)
  3515. if coin == 0:
  3516. message.add('A '+self.npcs[y][x].name+' throws a bomb!')
  3517. replace = self.tilemap[pos[1]][pos[0]]
  3518. self.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['effect'][0])
  3519. self.countdowns.append(countdown('bomb3',pos[0],pos[1],1))
  3520. self.tilemap[pos[1]][pos[0]].replace = replace
  3521. else:
  3522. message.add('A '+self.npcs[y][x].name+' throws an explosive!')
  3523. replace = self.tilemap[pos[1]][pos[0]]
  3524. self.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['effect'][7])
  3525. self.tilemap[pos[1]][pos[0]].replace = replace
  3526. self.npcs[y][x].move_done = 1
  3527. self.npcs[y][x].num_special -= 1
  3528. if self.npcs[y][x].move_done == 0:
  3529. player.monster_attacks(x,y)
  3530. self.npcs[y][x].move_done = 1#set the move_done switch on
  3531. elif self.npcs[y][x].AI_style == 'flee':
  3532. 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
  3533. if len(moves) > 1:
  3534. ran = random.randint(0,len(moves)-1)
  3535. else:
  3536. ran = 0
  3537. do_move = moves[ran]
  3538. else:
  3539. if len(moves) > 0:#if no move is possible at least the 'move' of stay still must remain
  3540. good_moves = []
  3541. for k in range (0, len(moves)):
  3542. 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
  3543. good_moves.append(moves[k])
  3544. else:
  3545. good_moves = moves
  3546. if len(good_moves) == 0:
  3547. good_moves = moves
  3548. if len(good_moves) > 1:
  3549. ran = random.randint(0,len(good_moves)-1)
  3550. else:
  3551. ran = 0
  3552. do_move = good_moves[ran]
  3553. elif self.npcs[y][x].AI_style == 'ignore':
  3554. if len(moves) > 1:
  3555. ran = random.randint(0,len(moves)-1)
  3556. else:
  3557. ran = 0
  3558. do_move = moves[ran]
  3559. #IV. Move the monster
  3560. if do_move != 'foo':
  3561. border = random.randint(1,9)
  3562. if border > self.npcs[y][x].move_border:
  3563. self.npcs[y][x].move_done = 1#set the move_done switch on
  3564. helper = self.npcs[y][x]#copy the monster
  3565. self.npcs[y][x] = 0 #del the monster at the old position
  3566. self.npcs[do_move[1]][do_move[0]] = helper# set monster to the new position
  3567. def monster_die(self,x,y,xp = None):
  3568. #this function is called when the player kills a monster. the x and the y variables are to define the location of the monster
  3569. monster_x = x
  3570. monster_y = y
  3571. real_drop = False
  3572. if self.tilemap[y][x].replace == None:
  3573. test_replace = True
  3574. else:
  3575. test_replace = False
  3576. if self.npcs[monster_y][monster_x].corps_style == 'make_blobs':
  3577. test_replace = True
  3578. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' vanishes!'
  3579. if test_replace != True or self.tilemap[y][x].drops_here != True:
  3580. location_list = [(monster_x,monster_y),]
  3581. for yy in range(y-1,y+2):
  3582. for xx in range(x-1,x+2):
  3583. if self.tilemap[yy][xx].replace == None and self.npcs[yy][xx] == 0:
  3584. test_replace = True
  3585. else:
  3586. test_replace = False
  3587. if test_replace == True and self.tilemap[yy][xx].drops_here and self.tilemap[yy][xx].move_group == 'soil':
  3588. location_list.append((xx,yy))
  3589. if len(location_list) > 1:
  3590. del location_list[0]
  3591. if len(location_list) == 1:
  3592. x = location_list[0][0]
  3593. y = location_list[0][1]
  3594. else:
  3595. ran = random.randint(0,len(location_list)-1)
  3596. x = location_list[ran][0]
  3597. y = location_list[ran][1]
  3598. if test_replace == True and self.tilemap[y][x].drops_here: #only on empty fields corps can be spawned
  3599. 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
  3600. coin = random.randint(0,99)
  3601. if coin < 50:#there is a chance of 50%
  3602. replace = self.tilemap[y][x]
  3603. self.tilemap[y][x] = tl.tlist['local'][10]#<---sepling
  3604. self.tilemap[y][x].replace = replace
  3605. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' turns into a new tree!'
  3606. 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
  3607. coin = random.randint(0,99)
  3608. if coin < 50:#there is a chance of 50%
  3609. replace = self.tilemap[y][x]
  3610. self.tilemap[y][x] = deepcopy(tl.tlist['local'][14])#<---rock
  3611. self.tilemap[y][x].replace = replace
  3612. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' turns to stone!'
  3613. 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
  3614. coin = random.randint(0,99)
  3615. if coin < 15:#there is a chance of 15%
  3616. real_drop = True
  3617. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' dies!'
  3618. replace = self.tilemap[y][x]
  3619. self.tilemap[y][x] = deepcopy(tl.tlist['functional'][6])#<--humanoid remains
  3620. self.tilemap[y][x].replace = replace
  3621. items = []
  3622. max_items = max(1,self.npcs[monster_y][monster_x].corps_lvl)
  3623. for i in range (0, max_items):
  3624. #possible drops of a humanoid monster are equipment items and food items
  3625. coin = random.randint(0,99)
  3626. if coin < 65: #there is a chance of 65% that a item becomes a eqipment item
  3627. material = random.randint(0,20) #all materials are allowed
  3628. classes = ('spear','sword','axe','hammer','shoes','cuisse','helmet','armor','wand','rune','rune staff','artefact','ring','amulet','necklace','talisman','pickaxe')
  3629. kind = classes[random.randint(0,len(classes)-1)]#all classes of objects are allowed
  3630. plus = random.randint(-2,+2)# a plus between -2 and +2 is possible
  3631. state = random.randint(10,85)#the state of this used objects will always be between 10% and 80%
  3632. curse_chance = random.randint(0,30)
  3633. if curse_chance < material:
  3634. curse = 0
  3635. elif curse_chance == material:
  3636. curse = 2
  3637. else:
  3638. curse = 1
  3639. item = item_wear(kind,material,plus,state,curse)
  3640. elif coin < 68: #there is a chance of 3% to drop a simple blueprint
  3641. blueprint = random.randint(15,20)
  3642. item = deepcopy(il.ilist['misc'][blueprint])
  3643. elif coin < 80: #there is a chance of 12% to drop a torch or a throwable:
  3644. 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])
  3645. ran = random.randint(0,len(item_list)-1)
  3646. item = deepcopy(item_list[ran])
  3647. else:
  3648. coin2 = random.randint(0,1)
  3649. if coin == 1:
  3650. item = deepcopy(il.ilist['food'][random.randint(0,len(il.ilist['food'])-1)])
  3651. else:
  3652. item_list = (il.ilist['misc'][74],il.ilist['misc'][75],il.ilist['misc'][76],il.ilist['misc'][77])
  3653. ran = random.randint(0,len(item_list)-1)
  3654. item = deepcopy(item_list[ran])
  3655. items.append(item)
  3656. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  3657. 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
  3658. coin = random.randint(0,99)
  3659. if coin < 15:#there is a chance of 15%
  3660. real_drop = True
  3661. replace = self.tilemap[y][x]
  3662. self.tilemap[y][x] = deepcopy(tl.tlist['functional'][21])#<--animal remains
  3663. self.tilemap[y][x].replace = replace
  3664. items = []
  3665. max_items = max(1,self.npcs[monster_y][monster_x].corps_lvl)
  3666. for i in range (0, max_items):
  3667. #animals drop flesh. the corpslvl says how much
  3668. items.append(deepcopy(il.ilist['food'][9]))#<---raw meat
  3669. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  3670. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' dies!'
  3671. 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
  3672. coin = random.randint(0,99)
  3673. if coin < 10:#there is a chance of 10%
  3674. real_drop = True
  3675. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' dies!'
  3676. replace = self.tilemap[y][x]
  3677. self.tilemap[y][x] = deepcopy(tl.tlist['functional'][6])#<--humanoid remains
  3678. self.tilemap[y][x].replace = replace
  3679. items = []
  3680. max_items = max(1,self.npcs[monster_y][monster_x].corps_lvl)
  3681. for i in range (0, max_items):
  3682. #possible drops of a scrollkeeper are scrolls and spellbooks
  3683. coin = random.randint(0,99)
  3684. if coin < 75: #there is a chance of 75% that a item becomes a scroll
  3685. 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])
  3686. ran = random.randint(0,len(scrolls)-1)
  3687. item = deepcopy(scrolls[ran])
  3688. else:
  3689. 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])
  3690. ran = random.randint(0,len(books)-1)
  3691. item = deepcopy(books[ran])
  3692. items.append(item)
  3693. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  3694. elif self.npcs[monster_y][monster_x].corps_style == 'miner':
  3695. if self.npcs[monster_y][monster_x].techID == ml.mlist['special'][0].techID:#this is a vase
  3696. die_mess = 'The vase shatters.'
  3697. ran = random.randint(0,99)
  3698. if ran <= self.npcs[monster_y][monster_x].corps_lvl: #for miners the corps_lvl determinates the chance of getting a gem
  3699. real_drop = True
  3700. replace = self.tilemap[y][x]
  3701. self.tilemap[y][x] = deepcopy(tl.tlist['misc'][9])#set a lost gem
  3702. self.tilemap[y][x].replace = replace
  3703. 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
  3704. real_drop = True
  3705. replace = self.tilemap[y][x]
  3706. self.tilemap[y][x] = deepcopy(tl.tlist['misc'][11])#set a lost ore
  3707. self.tilemap[y][x].replace = replace
  3708. elif self.npcs[monster_y][monster_x].corps_style == 'thief':
  3709. if self.tilemap[y][x].replace == None and self.npcs[monster_y][monster_x].corps_lvl > 0:
  3710. real_drop = True
  3711. replace = self.tilemap[y][x]
  3712. self.tilemap[y][x] = deepcopy(tl.tlist['misc'][9])#set a lost gem
  3713. self.tilemap[y][x].replace = replace
  3714. 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
  3715. elif self.npcs[monster_y][monster_x].corps_style == 'reset_parent':
  3716. parent_id = self.npcs[monster_y][monster_x].personal_id.replace('_child','')
  3717. for yy in range(0,max_map_size):
  3718. for xx in range(0,max_map_size):
  3719. if self.npcs[yy][xx] != 0:
  3720. if self.npcs[yy][xx].personal_id == parent_id:
  3721. self.npcs[yy][xx].num_special += 1
  3722. elif self.npcs[monster_y][monster_x].corps_style == 'kill_childs':
  3723. child_id = self.npcs[monster_y][monster_x].personal_id + '_child'
  3724. for yy in range(0,max_map_size):
  3725. for xx in range(0,max_map_size):
  3726. if self.npcs[yy][xx] != 0:
  3727. if self.npcs[yy][xx].personal_id == child_id:
  3728. self.npcs[yy][xx] = 0
  3729. elif self.npcs[monster_y][monster_x].corps_style == 'kobold_fear':
  3730. for yy in range(y-7,y+8):
  3731. for xx in range(x-7,x+8):
  3732. try:
  3733. if self.npcs[yy][xx].techID == ml.mlist['kobold'][1].techID and self.npcs[yy][xx].name != 'frightened kobold':
  3734. self.npcs[yy][xx] = deepcopy(self.npcs[yy][xx])#only to be sure
  3735. self.npcs[yy][xx].name = 'frightened kobold'
  3736. self.npcs[yy][xx].sprite_pos = (5,3)
  3737. self.npcs[yy][xx].basic_attribute.p_strength = int(self.npcs[yy][xx].basic_attribute.p_strength*0.6)
  3738. self.npcs[yy][xx].basic_attribute.m_strength = int(self.npcs[yy][xx].basic_attribute.m_strength*0.6)
  3739. self.npcs[yy][xx].basic_attribute.p_defense = int(self.npcs[yy][xx].basic_attribute.p_defense*0.6)
  3740. self.npcs[yy][xx].basic_attribute.m_defense = int(self.npcs[yy][xx].basic_attribute.m_defense*0.6)
  3741. screen.write_hit_matrix(xx,yy,17)
  3742. coin = random.randint(0,1)
  3743. if coin == 1:
  3744. self.npcs[yy][xx].AI_style = 'flee'
  3745. except:
  3746. None
  3747. elif self.npcs[monster_y][monster_x].corps_style == 'vase':
  3748. die_mess = 'The vase shatters and monsters jump out.'
  3749. monster_count = 0
  3750. for yy in range(y-1,y+2):
  3751. for xx in range(x-1,x+2):
  3752. if yy != player.pos[1] or xx!= player.pos[0]:
  3753. if self.npcs[yy][xx] == 0 and self.tilemap[yy][xx].move_group == 'soil' and self.tilemap[yy][xx].damage == 0:
  3754. self.npcs[yy][xx] = deepcopy(ml.mlist['special'][2])#set vase monsters
  3755. self.set_monster_strength(xx,yy,player.pos[2])
  3756. if player.difficulty == 4:
  3757. self.npcs[yy][xx].AI_style = 'ignore'
  3758. monster_count += 1
  3759. if monster_count > 0:
  3760. die_mess = 'The vase shatters and '+str(monster_count)+' monsters jump out.'
  3761. else:
  3762. die_mess = 'The vase shatters.'
  3763. elif self.npcs[monster_y][monster_x].corps_style == 'mimic':
  3764. die_mess = 'The mimic wakes up.'
  3765. elif self.npcs[monster_y][monster_x].corps_style == 'cage_low' or self.npcs[monster_y][monster_x].corps_style == 'cage_medium' or self.npcs[monster_y][monster_x].corps_style == 'cage_high':
  3766. die_mess = 'You smash the cage!'
  3767. sfx.play('destroy_cage')
  3768. elif self.npcs[monster_y][monster_x].corps_style == 'make_blobs':
  3769. counter = 0
  3770. blob_lvl = max(self.npcs[monster_y][monster_x].lvl-1,0)
  3771. for yy in range(y-1,y+2):
  3772. for xx in range(x-1,x+2):
  3773. if yy != y or xx != x:
  3774. not_player_pos = yy != player.pos[1] or xx != player.pos[0]
  3775. if self.tilemap[yy][xx].move_group == 'soil' and not_player_pos == True and self.npcs[yy][xx] == 0:
  3776. self.npcs[yy][xx] = deepcopy(ml.mlist['special'][15])#set a green blob
  3777. self.set_monster_strength(xx,yy,player.pos[2],preset_lvl=blob_lvl)
  3778. if player.difficulty == 4:
  3779. self.npcs[yy][xx].AI_style = 'ignore'
  3780. counter += 1
  3781. if counter == 1:
  3782. die_mess = 'The giant blob leaves behind a small blob.'
  3783. elif counter > 1:
  3784. die_mess = 'The giant blob bursts into '+str(counter)+' small blobs.'
  3785. elif self.npcs[monster_y][monster_x].corps_style == 'vanish':
  3786. ran = random.randint(0,99)
  3787. if ran <= self.npcs[monster_y][monster_x].corps_lvl: #the corps_lvl determinates the chance of getting a present
  3788. real_drop = True
  3789. replace = self.tilemap[y][x]
  3790. self.tilemap[y][x] = deepcopy(tl.tlist['misc'][13])#set a present
  3791. self.tilemap[y][x].replace = replace
  3792. item_ran = random.randint(0,99)
  3793. if item_ran < 25:
  3794. items = [il.ilist['misc'][43]]#set a heavy bag
  3795. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  3796. elif item_ran < 50:
  3797. choose_ran = random.randint(0,len(il.ilist['clothe'])-1)
  3798. items = [il.ilist['clothe'][choose_ran]]
  3799. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  3800. elif item_ran < 95:
  3801. r = random.randint(3,7)
  3802. items = [il.ilist['misc'][r]]#set a workbench
  3803. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  3804. else:
  3805. items = [il.ilist['misc'][70]]#set a book of skill
  3806. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  3807. ############ADD MORE HERE###############
  3808. if real_drop == True:
  3809. screen.write_hit_matrix(x,y,16)
  3810. if self.npcs[monster_y][monster_x].move_border < 10:
  3811. screen.write_hit_matrix(monster_x,monster_y,13)
  3812. if self.npcs[monster_y][monster_x].corps_style == 'mimic':
  3813. self.npcs[monster_y][monster_x] = deepcopy(ml.mlist['special'][4])#set a mimic
  3814. self.set_monster_strength(monster_x,monster_y,player.pos[2])
  3815. if player.difficulty == 4:
  3816. self.npcs[monster_y][monster_x].AI_style = 'ignore'
  3817. elif self.npcs[monster_y][monster_x].corps_style == 'cage_low' or self.npcs[monster_y][monster_x].corps_style == 'cage_medium' or self.npcs[monster_y][monster_x].corps_style == 'cage_high':
  3818. list_name = self.npcs[monster_y][monster_x].corps_style.replace('cage_','')
  3819. player.villager[list_name].append(self.npcs[monster_y][monster_x].corps_lvl)
  3820. self.npcs[monster_y][monster_x] = deepcopy(ml.mlist['rescued'][self.npcs[monster_y][monster_x].corps_lvl])
  3821. self.set_monster_strength(monster_x,monster_y,player.pos[2])
  3822. else:
  3823. self.npcs[monster_y][monster_x] = 0 #always del the monster if it is no mimic or cage
  3824. self.make_monsters_angry(monster_x,monster_y,'kill')
  3825. self.monster_count -= 1
  3826. if xp != None:
  3827. die_mess = die_mess + ' [+' + str(xp) + 'xp]'
  3828. message.add(die_mess)
  3829. return True
  3830. def make_shops(self):
  3831. num = int((max_map_size*max_map_size) / (50*50))
  3832. for i in range (0,num):
  3833. run = True
  3834. while run:
  3835. poses = self.find_all_moveable(False,False)
  3836. ran = random.randint(0,len(poses)-1)
  3837. pos = poses[ran]
  3838. if min(pos[0],pos[1]) > 4 and max(pos[0],pos[1]) < max_map_size-4:
  3839. run = False
  3840. x = pos[0]
  3841. y = pos[1]
  3842. for yy in range(y-2,y+3):
  3843. for xx in range(x-2,x+3):
  3844. self.npcs[yy][xx] = 0 #always del the monsters
  3845. if xx == x-2 or xx == x+2 or yy == y-2 or yy == y+2:
  3846. self.tilemap[yy][xx] = deepcopy(tl.tlist['shop'][1])
  3847. else:
  3848. self.tilemap[yy][xx] = deepcopy(tl.tlist['shop'][0])
  3849. self.tilemap[y][x-2] = deepcopy(tl.tlist['shop'][2])
  3850. self.tilemap[y][x+2] = deepcopy(tl.tlist['shop'][2])
  3851. self.tilemap[y-2][x] = deepcopy(tl.tlist['shop'][2])
  3852. self.tilemap[y+2][x] = deepcopy(tl.tlist['shop'][2])
  3853. if self.map_type == 'orcish_mines':
  3854. self.npcs[y][x] = deepcopy(ml.mlist['shop'][1])
  3855. elif self.map_type == 'grot':
  3856. self.npcs[y][x] = deepcopy(ml.mlist['shop'][2])
  3857. else:
  3858. 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
  3859. def make_monsters_angry(self,x,y,style):
  3860. for yy in range(y-3,y+4):
  3861. for xx in range(x-3,x+4):
  3862. try:
  3863. if self.npcs[yy][xx] != 0:
  3864. if self.npcs[yy][xx].anger == style:
  3865. lvl = self.npcs[yy][xx].lvl
  3866. self.npcs[yy][xx] = deepcopy(ml.mlist['angry_monster'][self.npcs[yy][xx].anger_monster])
  3867. self.set_monster_strength(xx,yy,player.pos[2],lvl)
  3868. if player.difficulty == 4:
  3869. self.npcs[yy][xx].AI_style = 'ignore'
  3870. except:
  3871. None
  3872. def time_pass(self):
  3873. #This function refresches the map for every day that past since players last visit... make plants growing etc.
  3874. if self.last_visit != time.day_total:
  3875. screen.render_load(10)
  3876. past_time = time.day_total - self.last_visit
  3877. if past_time < 0:
  3878. past_time = 364 - past_time
  3879. for c in range (0,past_time):
  3880. for y in range (0,max_map_size):
  3881. for x in range(0,max_map_size):
  3882. tile = self.tilemap[y][x]
  3883. #######Life of plants######
  3884. #1. Scrub
  3885. if tile.grow_group == 'scrub':
  3886. rand = random.randint(0,99)
  3887. if rand < 50:
  3888. replace = self.tilemap[y][x].replace
  3889. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  3890. self.tilemap[y][x].replace = replace
  3891. if tile.grow_group == 'scrub_buds':
  3892. rand = random.randint(0,99)
  3893. if rand < 90:
  3894. replace = self.tilemap[y][x].replace
  3895. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  3896. self.tilemap[y][x].replace = replace
  3897. if tile.grow_group == 'scrub_blossom':
  3898. rand = random.randint(0,99)
  3899. if rand < 80:
  3900. scrubs = random.randint(0,2)
  3901. replace = self.tilemap[y][x].replace
  3902. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[scrubs][0]][tile.conected_tiles[scrubs][1]])
  3903. self.tilemap[y][x].replace = replace
  3904. if tile.grow_group == 'scrub_berries':
  3905. rand = random.randint(0,99)
  3906. if rand < 50:
  3907. replace = self.tilemap[y][x].replace
  3908. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0][0]][tile.conected_tiles[0][1]])
  3909. self.tilemap[y][x].replace = replace
  3910. elif rand > 49 and rand < 75:
  3911. numbers =(-1,1)
  3912. for yy in numbers:
  3913. for xx in numbers:
  3914. try:
  3915. if self.tilemap[y+yy][x+xx].can_grown == True:
  3916. coin = random.randint(0,99)
  3917. if coin < 25: #25%
  3918. replace = self.tilemap[y+yy][x+xx]
  3919. self.tilemap[y+yy][x+xx] = deepcopy([tile.conected_tiles[1][0]][tile.conected_tiles[1][1]])
  3920. self.tilemap[y+yy][x+xx].replace = replace
  3921. except:
  3922. None
  3923. if tile.grow_group == 'scrub_scruffy':
  3924. rand = random.randint(0,99)
  3925. if rand < 90:
  3926. replace = self.tilemap[y][x].replace
  3927. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0][0]][tile.conected_tiles[0][1]])
  3928. self.tilemap[y][x].replace = replace
  3929. else:
  3930. replace = self.tilemap[y][x].replace
  3931. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[1][0]][tile.conected_tiles[1][1]])
  3932. self.tilemap[y][x].replace = replace
  3933. if tile.grow_group == 'scrub_grow':
  3934. rand = random.randint(0,99)
  3935. if rand < 90:
  3936. replace = self.tilemap[y][x].replace
  3937. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  3938. self.tilemap[y][x].replace = replace
  3939. #2.Tree
  3940. if tile.grow_group == 'tree_grow':
  3941. rand = random.randint(0,99)
  3942. if rand < 80 and self.npcs[y][x] == 0:
  3943. replace = self.tilemap[y][x].replace
  3944. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  3945. self.tilemap[y][x].replace = replace
  3946. if tile.grow_group == 'tree':
  3947. rand = random.randint(0,99)
  3948. if rand < 5:
  3949. replace = self.tilemap[y][x].replace
  3950. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[1][0]][tile.conected_tiles[1][1]])
  3951. self.tilemap[y][x].replace = replace
  3952. elif rand > 69:
  3953. numbers =(-2,2)
  3954. for yy in numbers:
  3955. for xx in numbers:
  3956. try:
  3957. if self.tilemap[y+yy][x+xx].can_grown == True:
  3958. coin = random.randint(0,3)
  3959. if coin == 0:
  3960. replace = self.tilemap[y+yy][x+xx]
  3961. self.tilemap[y+yy][x+xx] = deepcopy(tl.tlist[tile.conected_tiles[0][0]][tile.conected_tiles[0][1]])
  3962. self.tilemap[y+yy][x+xx].replace = replace
  3963. except:
  3964. None
  3965. #3.Herb
  3966. if tile.grow_group == 'herblike':
  3967. rand = random.randint(0,99)
  3968. if rand < 20:
  3969. replace = self.tilemap[y][x].replace
  3970. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  3971. self.tilemap[y][x].replace = replace
  3972. #4. Blue Mushrooms
  3973. if tile.grow_group == 'mushroom_mud':
  3974. rand = random.randint(0,99)
  3975. if rand < 5:
  3976. for yy in range(-1,1):
  3977. for xx in range(-1,1):
  3978. try:
  3979. if self.tilemap[y+yy][x+xx].techID == tl.tlist['misc'][1].techID:#here is mud
  3980. cent = random.randint(0,99)
  3981. if cent < 25 :
  3982. replace = self.tilemap[y+yy][x+xx]
  3983. self.tilemap[y+yy][x+xx] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  3984. self.tilemap[y+yy][x+xx].replace = replace
  3985. except:
  3986. None
  3987. #5. Brown Mushrooms
  3988. if tile.grow_group == 'mushroom_treelike':
  3989. rand = random.randint(0,99)
  3990. if rand < 5:
  3991. for yy in range(-1,1):
  3992. for xx in range(-1,1):
  3993. try:
  3994. if self.tilemap[y+yy][x+xx].techID == tl.tlist['global_caves'][0].techID:#here is cave ground
  3995. cent = random.randint(0,99)
  3996. if cent < 25 :
  3997. replace = self.tilemap[y+yy][x+xx]
  3998. self.tilemap[y+yy][x+xx] = deepcopy(tl.tlist[tile.conected_tiles[0][0]][tile.conected_tiles[0][1]])
  3999. self.tilemap[y+yy][x+xx].replace = replace
  4000. except:
  4001. None
  4002. elif rand < 30:#make a giant mushroom
  4003. replace = self.tilemap[y][x].replace
  4004. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[1][0]][tile.conected_tiles[1][1]])
  4005. self.tilemap[y][x].replace = replace
  4006. #6. Purple Mushrooms
  4007. if tile.grow_group == 'mushroom': #let grow new mushrooms and let the old ones die(5%)
  4008. rand = random.randint(0,99)
  4009. if rand < 5:
  4010. for yy in range(-1,1):
  4011. for xx in range(-1,1):
  4012. try:
  4013. if self.tilemap[y+yy][x+xx].techID == tl.tlist['global_caves'][0].techID:#here is cave ground
  4014. cent = random.randint(0,99)
  4015. if cent < 25 :
  4016. replace = self.tilemap[y+yy][x+xx]
  4017. self.tilemap[y+yy][x+xx] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  4018. self.tilemap[y+yy][x+xx].replace = replace
  4019. except:
  4020. None
  4021. #7. Agriculture
  4022. if tile.grow_group == 'agri0':
  4023. rand = random.randint(0,99)
  4024. if rand < 50:
  4025. if self.map_type == 'overworld':
  4026. self.tilemap[y][x] = tl.tlist[tile.conected_tiles[0][0]][tile.conected_tiles[0][1]]
  4027. elif self.map_type == 'cave' or self.map_type == 'desert_cave':
  4028. self.tilemap[y][x] = tl.tlist[tile.conected_tiles[1][0]][tile.conected_tiles[1][1]]
  4029. elif self.map_type == 'desert':
  4030. self.tilemap[y][x] = tl.tlist[tile.conected_tiles[2][0]][tile.conected_tiles[2][1]]
  4031. if tile.grow_group == 'agri1': #let something grow on a acriculture (final, at the overworld) (50%)
  4032. rand = random.randint(0,99)
  4033. if rand < 50:
  4034. self.tilemap[y][x] = tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]]
  4035. #8. Vanish
  4036. if tile.grow_group == 'vanish':
  4037. rand = random.randint(0,99)
  4038. if rand < 50:
  4039. self.tilemap[y][x] = self.tilemap[y][x].replace
  4040. self.containers[y][x] = 0
  4041. #9. Magic shops
  4042. if tile.techID == tl.tlist['shop'][4].techID and player.on_map != 'shop_0_0':
  4043. self.tilemap[y][x] = self.tilemap[y][x].replace
  4044. #######Misc#######
  4045. #0. Rubble
  4046. if tile.techID == tl.tlist['functional'][26].techID:
  4047. rand = random.randint(0,99)
  4048. if rand < 20:
  4049. count_rubble = 0
  4050. count_sand = 0
  4051. count_grass = 0
  4052. count_cave = 0
  4053. for yy in range(y-1,y+2):
  4054. for xx in range(x-1,x+2):
  4055. if self.tilemap[yy][xx].techID == tl.tlist['functional'][26]:#this is rubble
  4056. count_rubble += 1
  4057. elif self.tilemap[yy][xx].techID == tl.tlist['local'][0]:#this is grass
  4058. count_grass += 1
  4059. elif self.tilemap[yy][xx].techID == tl.tlist['extra'][0]:#this is sand
  4060. count_sand += 1
  4061. elif self.tilemap[yy][xx].techID == tl.tlist['global_caves'][0]:#this is cave
  4062. count_cave +=1
  4063. if count_rubble < 8: #this tile isnt surrounded by rubble
  4064. if count_cave > 1:
  4065. self.tilemap[y][x] = deepcopy(tl.tlist['global_caves'][0])
  4066. elif count_grass >= count_sand:
  4067. self.tilemap[y][x] = deepcopy(tl.tlist['local'][0])
  4068. else:
  4069. self.tilemap[y][x] = deepcopy(tl.tlist['extra'][0])
  4070. #########add other events for growing plants etc here########
  4071. 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
  4072. for i in range(0,len(player.inventory.food)):#let the food rot in the players inventory
  4073. if player.inventory.food[i] != player.inventory.nothing:
  4074. player.inventory.food[i].rot()
  4075. if player.on_map != 'shop_0_0':
  4076. shop_num = int((max_map_size**2)/(50**2))
  4077. self.spawn_magic_shops(shop_num)
  4078. screen.render_load(5)
  4079. save(world,player,time,gods,save_path,os.sep)
  4080. def exchange(self,old_tile,new_tile,use_deepcopy=False):
  4081. for y in range (0,max_map_size):
  4082. for x in range (0,max_map_size):
  4083. if self.tilemap[y][x].techID == old_tile.techID:
  4084. if use_deepcopy == False:
  4085. self.tilemap[y][x] = new_tile
  4086. else:
  4087. self.tilemap[y][x] = deepcopy(new_tile)
  4088. def find_first(self,tile):
  4089. for y in range (0,max_map_size):
  4090. for x in range (0,max_map_size):
  4091. if self.tilemap[y][x].techID == tile.techID:
  4092. return [x,y]
  4093. if self.tilemap[y][x].name == tile.name:#fallback
  4094. return [x,y] #
  4095. return False
  4096. def find_any(self,tile):
  4097. found = []
  4098. for y in range(0,max_map_size):
  4099. for x in range(0,max_map_size):
  4100. if self.tilemap[y][x].techID == tile.techID and self.npcs[y][x] == 0:
  4101. found.append((x,y))
  4102. if found == []:
  4103. return False
  4104. elif len(found) == 1:
  4105. return found[0]
  4106. else:
  4107. ran = random.randint(0,len(found)-1)
  4108. return found[ran]
  4109. def find_all_moveable(self,ignore_water = True,ignore_player_pos = False, ignore_no_spawn = True):
  4110. cordinates_list = []
  4111. for y in range (0, max_map_size):
  4112. for x in range (0,max_map_size):
  4113. moveable = False
  4114. if ignore_water == True:
  4115. if self.tilemap[y][x].move_group == 'soil':
  4116. moveable = True
  4117. else:
  4118. if self.tilemap[y][x].move_group == 'soil' or self.tilemap[y][x].move_group == 'low_liquid':
  4119. moveable = True
  4120. if ignore_player_pos == True:
  4121. player_pos_check = False
  4122. else:
  4123. if (x - entrance_x < -7) or (y - entrance_y < -7) or (x - entrance_x > 7) or (y - entrance_y > 7):
  4124. player_pos_check = False
  4125. else:
  4126. player_pos_check = True
  4127. spawn_check = True
  4128. if ignore_no_spawn == False:
  4129. if self.tilemap[y][x].no_spawn == True:
  4130. spawn_check = False
  4131. 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:
  4132. cordinates_list.append((x,y))
  4133. if len(cordinates_list) > 0:
  4134. return cordinates_list
  4135. else:
  4136. return False
  4137. def add_container(self, inventory, x, y, deep_copy = True, checkIt = False):
  4138. self.containers[y][x] = container(inventory,deep_copy)
  4139. if checkIt == True:
  4140. if self.check_container(x,y) != True:
  4141. print('Container creation failed!')
  4142. self.containers[y][x] = 0
  4143. self.tilemap[y][x] = self.tilemap[y][x].replace
  4144. def check_container(self,x,y):
  4145. if self.tilemap[y][x].replace != None and len(self.containers[y][x].items) > 0:
  4146. return True
  4147. else:
  4148. return False
  4149. def special_check(self,x,y):
  4150. sfx_flame = False
  4151. sfx_vapor = False
  4152. for yy in range(y-7,y+8):
  4153. for xx in range(x-7,x+8):
  4154. try:
  4155. if (self.tilemap[yy][xx].special_group == 'flamable' or self.tilemap[yy][xx].special_group == 'highly flamable') and self.tilemap[yy][xx].replace != None:
  4156. heat_source = 0
  4157. for yyy in range(yy-1,yy+2):
  4158. for xxx in range(xx-1,xx+2):
  4159. try:
  4160. if self.tilemap[yyy][xxx].special_group == 'hot':
  4161. heat_source += 1
  4162. except:
  4163. None
  4164. if heat_source > 0:
  4165. if self.tilemap[yy][xx].special_group == 'flamable':
  4166. ran = random.randint(0,9)
  4167. else:
  4168. ran = 9
  4169. if ran > 5:
  4170. sfx_flame = True
  4171. self.containers[yy][xx] = 0
  4172. self.countdowns.append(countdown('flame',xx,yy,self.tilemap[yy][xx].special_num))
  4173. replace = self.tilemap[yy][xx].replace
  4174. self.tilemap[yy][xx] = deepcopy(tl.tlist['effect'][4])
  4175. self.tilemap[yy][xx].replace = replace
  4176. elif self.tilemap[yy][xx].special_group == 'explosive' or self.tilemap[yy][xx].special_group == 'highly explosive':
  4177. heat_sources = 0
  4178. for yyy in range(yy-1,yy+2):
  4179. for xxx in range(xx-1,xx+2):
  4180. try:
  4181. if self.tilemap[yyy][xxx].special_group == 'hot':
  4182. heat_sources += 1
  4183. except:
  4184. None
  4185. if heat_sources > 0:
  4186. if self.tilemap[yyy][xxx].special_group == 'explosive':
  4187. ran = random.randint(0,9)
  4188. else:
  4189. ran = 9
  4190. if ran > 5:
  4191. self.countdowns.append(countdown('bomb1',xx,yy,1))
  4192. for yyy in range(yy-1,yy+2):
  4193. for xxx in range(xx-1,xx+2):
  4194. try:
  4195. if self.tilemap[yyy][xxx].special_group == 'explosive' or elf.tilemap[yyy][xxx].special_group == 'highly explosive':
  4196. self.countdowns.append(countdown('bomb1',xxx,yyy,1))
  4197. except:
  4198. None
  4199. elif self.tilemap[yy][xx].special_group == 'vaporable':
  4200. heat_sources = 0
  4201. for yyy in range(yy-1,yy+2):
  4202. for xxx in range(xx-1,xx+2):
  4203. try:
  4204. if self.tilemap[yyy][xxx].special_group == 'hot':
  4205. heat_sources += 1
  4206. except:
  4207. None
  4208. if heat_sources >= self.tilemap[yy][xx].special_num:
  4209. sfx.vapor = True
  4210. self.tilemap[yy][xx] = deepcopy(tl.tlist['misc'][1])#mud
  4211. except:
  4212. None
  4213. if sfx_flame == True:
  4214. sfx.play('flame')
  4215. if sfx_vapor == True:
  4216. sfx.play('steam')
  4217. def spawn_monster_groups(self,leader,follower,max_group_size):
  4218. for y in range(0,max_map_size):
  4219. for x in range(0,max_map_size):
  4220. if self.npcs[y][x] != 0 and self.npcs[y][x].techID == leader.techID:
  4221. m_count = 1
  4222. for yy in range(y-1,y+2):
  4223. for xx in range(x-1,x+2):
  4224. if m_count < max_group_size and self.npcs[yy][xx] == 0 and self.tilemap[yy][xx].move_group in follower.move_groups:
  4225. self.npcs[yy][xx] = deepcopy(follower)
  4226. self.set_monster_strength(xx,yy,max(self.npcs[y][x].lvl-5,1))
  4227. if player.difficulty == 4:
  4228. self.npcs[yy][xx].AI_style = 'ignore'
  4229. m_count += 1
  4230. def make_special_monsters(self, min_no, max_no, on_tile, depth, monster_type='vase'):
  4231. size = int((max_map_size*max_map_size)/(50*50))
  4232. for i in range(0,size):
  4233. num_monster = random.randint(min_no,max_no)
  4234. if num_monster > 0:
  4235. for z in range (0,num_monster):
  4236. pos = self.find_any(on_tile)
  4237. if monster_type == 'vase':
  4238. ran = random.randint(0,99)
  4239. if ran < 10:
  4240. self.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['special'][1]) #spawn a monster vase
  4241. self.npcs[pos[1]][pos[0]].attribute = attribute(0,0,0,0,0,1,0)
  4242. else:
  4243. self.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['special'][0]) #spawn a vase
  4244. self.npcs[pos[1]][pos[0]].attribute = attribute(0,0,0,0,0,1,0)
  4245. elif monster_type == 'mimic':
  4246. pos = self.find_any(on_tile)
  4247. self.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['special'][3]) #spawn a sleeping mimic
  4248. self.npcs[pos[1]][pos[0]].attribute = attribute(0,0,0,0,0,1,0)
  4249. elif monster_type == 'demonic chest':
  4250. pos = self.find_any(on_tile)
  4251. self.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['functional'][4])#cest
  4252. self.tilemap[pos[1]][pos[0]].replace = deepcopy(on_tile)
  4253. 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])
  4254. ran1 = random.randint(0,len(sb)-1)
  4255. ran2 = random.randint(0,len(sb)-1)
  4256. items = [sb[ran1],sb[ran2]]
  4257. self.containers[pos[1]][pos[0]] = container(items,True)
  4258. self.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['special'][14])
  4259. self.set_monster_strength(pos[0],pos[1],depth)
  4260. #set monsters personal_id
  4261. 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))
  4262. def make_containers(self, min_no, max_no, on_tile, item_min, item_max, container_type='remains'):
  4263. size = int((max_map_size*max_map_size)/(50*50))
  4264. for i in range(0,size):
  4265. num_container = random.randint(min_no,max_no)
  4266. if num_container > 0:
  4267. for z in range (0,num_container):
  4268. c_type = container_type
  4269. if c_type == 'chest':
  4270. ch = random.randint(0,99)
  4271. if ch < 5:
  4272. c_type = 'fridge'
  4273. place = self.find_any(on_tile)
  4274. inventory = []
  4275. num_items = random.randint(item_min,item_max)##############item_min,item_max
  4276. for t in range (0,num_items):
  4277. if c_type == 'chest':
  4278. coin = random.randint(0,1)
  4279. if coin == 0:#add equipmen
  4280. classes = ['sword', 'axe', 'hammer', 'spear', 'helmet', 'armor', 'cuisse', 'shoes', 'wand', 'rune', 'rune staff', 'artefact', 'amulet', 'ring', 'talisman', 'necklace', 'pickaxe']
  4281. class_num = random.randint(0,len(classes)-1)
  4282. material = random.randint(0,20)
  4283. plus = random.randint(-3,3)
  4284. state = random.randint(80,100)
  4285. curse_chance = random.randint(0,30)
  4286. if curse_chance < material:
  4287. curse = 0
  4288. elif curse_chance == material:
  4289. curse = 2
  4290. else:
  4291. curse = 1
  4292. item = item_wear(classes[class_num], material, plus, state, curse, False)
  4293. inventory.append(item)
  4294. elif coin == 1:
  4295. items = []
  4296. for i in range(14,21):
  4297. items.append(il.ilist['misc'][i])
  4298. for i in range(22,40):
  4299. items.append(il.ilist['misc'][i])
  4300. for i in range(44,47):
  4301. items.append(il.ilist['misc'][i])
  4302. for j in range(6,9):
  4303. items.append(il.ilist['food'][j])
  4304. for j in range(13,25):
  4305. items.append(il.ilist['food'][j])
  4306. for j in range(29,32):
  4307. items.append(il.ilist['food'][j])
  4308. ran = random.randint(0,len(items)-1)
  4309. inventory.append(deepcopy(items[ran]))
  4310. elif c_type == 'remains':
  4311. classes = ['sword', 'axe', 'hammer', 'spear', 'helmet', 'armor', 'cuisse', 'shoes', 'wand', 'rune', 'rune staff', 'artefact', 'amulet', 'ring', 'talisman', 'necklace', 'pickaxe']
  4312. class_num = random.randint(0,len(classes)-1)
  4313. material = random.randint(0,20)
  4314. plus = random.randint(-3,3)
  4315. state = random.randint(20,60)
  4316. curses = (0,1,2)
  4317. curse_num = random.randint(0,2)
  4318. item = item_wear(classes[class_num], material, plus, state, curses[curse_num], False)
  4319. inventory.append(item)
  4320. elif c_type == 'fridge':
  4321. ran = random.randint(0,len(il.ilist['food'])-1)
  4322. inventory.append(deepcopy(il.ilist['food'][ran]))
  4323. if c_type == 'chest':
  4324. self.add_container(inventory, place[0], place[1])
  4325. replace = self.tilemap[place[1]][place[0]]
  4326. self.tilemap[place[1]][place[0]] = deepcopy(tl.tlist['functional'][4])#chest
  4327. self.tilemap[place[1]][place[0]].replace = replace
  4328. elif c_type == 'remains':
  4329. replace_tile = self.tilemap[place[1]][place[0]]
  4330. self.add_container(inventory, place[0], place[1])
  4331. self.tilemap[place[1]][place[0]] = deepcopy(tl.tlist['functional'][6])#remains
  4332. self.tilemap[place[1]][place[0]].replace = replace_tile
  4333. elif c_type == 'fridge':
  4334. replace_tile = self.tilemap[place[1]][place[0]]
  4335. self.add_container(inventory, place[0], place[1])
  4336. self.tilemap[place[1]][place[0]] = deepcopy(tl.tlist['functional'][25])#fridge
  4337. self.tilemap[place[1]][place[0]].replace = replace_tile
  4338. def exchange_when_surrounded(self, tile_check, tile_replace, number_neighbors):
  4339. #check all cordinates for their neighbors(including them self) and exchange th tile when the number of neighbors with the same techID => number_neighbors
  4340. for y in range (0,max_map_size):
  4341. for x in range (0,max_map_size):
  4342. count = 0
  4343. for yy in range (-1,2):
  4344. for xx in range (-1,2):
  4345. try:
  4346. if self.tilemap[y+yy][x+xx].techID == tile_check.techID or self.tilemap[y+yy][x+xx].techID == tile_replace.techID:
  4347. count += 1
  4348. except:
  4349. None
  4350. if count >= number_neighbors:
  4351. self.tilemap[y][x] = tile_replace
  4352. def sget(self):
  4353. string = ''
  4354. for c in range (0,max_map_size):
  4355. for d in range (0,max_map_size):
  4356. if d != player.pos[0] or c != player.pos[1]:
  4357. if self.known[c][d] != 0:
  4358. string = string + self.tilemap[c][d].char
  4359. else:
  4360. string += '\033[0;30;40m '
  4361. else:
  4362. string = string + player.char
  4363. string = string + '\n'
  4364. return string
  4365. def spawn_magic_shops(self,num=1):
  4366. if self.name == 'shop_0_0':
  4367. return False
  4368. pos = []
  4369. for i in range(0,num):
  4370. for y in range(0,max_map_size):
  4371. for x in range(0,max_map_size):
  4372. if self.tilemap[y][x].move_group == 'solid':
  4373. num_soil = 0
  4374. try:
  4375. if self.tilemap[y-1][x].move_group == 'soil':
  4376. num_soil += 1
  4377. except:
  4378. None
  4379. try:
  4380. if self.tilemap[y+1][x].move_group == 'soil':
  4381. num_soil += 1
  4382. except:
  4383. None
  4384. try:
  4385. if self.tilemap[y][x-1].move_group == 'soil':
  4386. num_soil += 1
  4387. except:
  4388. None
  4389. try:
  4390. if self.tilemap[y][x+1].move_group == 'soil':
  4391. num_soil += 1
  4392. except:
  4393. None
  4394. if num_soil > 0:
  4395. pos.append((x,y))
  4396. if len(pos) < 1:
  4397. return False
  4398. ran = random.randint(0,len(pos)-1)
  4399. replace = deepcopy(self.tilemap[pos[ran][1]][pos[ran][0]])
  4400. self.tilemap[pos[ran][1]][pos[ran][0]] = deepcopy(tl.tlist['shop'][4])
  4401. self.tilemap[pos[ran][1]][pos[ran][0]].replace = replace
  4402. #print('Shop at: '+str(pos[ran][0])+','+str(pos[ran][1]))
  4403. def set_sanctuary(self,startx,starty):
  4404. for y in range (starty-2, starty+3):
  4405. for x in range (startx-2, startx+3):
  4406. self.tilemap[y][x] = deepcopy(tl.tlist['sanctuary'][0])#sanctuary floor
  4407. if x == startx-2 or x == startx or x == startx+2:
  4408. if y == starty-2 or y == starty or y == starty+2:
  4409. self.tilemap[y][x] = deepcopy(tl.tlist['sanctuary'][1])#sanctuary pilar
  4410. self.tilemap[starty][startx] = deepcopy(tl.tlist['sanctuary'][2])#sanctuary spawn point
  4411. self.tilemap[starty-1][startx] = deepcopy(tl.tlist['functional'][20])#divine gift
  4412. self.tilemap[starty-1][startx].replace = tl.tlist['sanctuary'][0]
  4413. self.countdowns.append(countdown('gift_to_workbench',startx,starty-1,1))
  4414. material_pick = random.randint(0,10)
  4415. material_axe = random.randint(0,10)
  4416. material_amo = random.randint(0,10)
  4417. amo_classes = ('shoes','cuisse','armor','helmet')
  4418. ran = random.randint(0,3)
  4419. amo_class = amo_classes[ran]
  4420. pick = item_wear('pickaxe', material_pick,0)
  4421. axe = item_wear('axe',material_axe,0)
  4422. amo = item_wear(amo_class,material_amo,0)
  4423. ran_tunica = random.randint(0,2)
  4424. #original
  4425. 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)
  4426. #/original
  4427. # statue demo:
  4428. #list_t = [pick,axe]
  4429. #for f in range(55,70):
  4430. # list_t.append(il.ilist['misc'][f])
  4431. #self.add_container(list_t,startx,starty-1)
  4432. # 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)
  4433. # 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)
  4434. # 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)
  4435. self.tilemap[starty+1][startx] = deepcopy(tl.tlist['functional'][1])#stair down
  4436. self.tilemap[starty+1][startx].damage = -1
  4437. self.tilemap[starty+1][startx].damage_mes = 'Your wounds are cured.'
  4438. self.tilemap[starty+1][startx].build_here = False
  4439. self.tilemap[starty+1][startx].move_group = 'holy'
  4440. class world_class():
  4441. def __init__(self,tilelist):
  4442. global max_map_size
  4443. screen.render_load(0)
  4444. name = save_path + os.sep + 'world.data'
  4445. self.map_size = 52
  4446. self.startx = 0
  4447. self.starty = 0
  4448. try:
  4449. f = open(name, 'rb')
  4450. temp = p.load(f)
  4451. screen.render_load(1)
  4452. self.maplist = temp.maplist
  4453. self.map_size = temp.map_size
  4454. max_map_size = self.map_size
  4455. self.startx = temp.startx
  4456. self.starty = temp.starty
  4457. except:
  4458. screen.render_load(2)
  4459. if force_small_worlds == False:
  4460. self.choose_size()
  4461. self.maplist = []
  4462. for x in range (0,7):
  4463. self.maplist.append({})
  4464. screen.render_load(3)
  4465. pos = self.grassland_generator(0,0,30,80,5,int((max_map_size*max_map_size)/20))
  4466. self.startx = pos[0]
  4467. self.starty = pos[1]
  4468. self.cave_generator(4)
  4469. self.border_generator(6)
  4470. screen.render_load(5)
  4471. def default_map_generator(self, name, tiles, tilelist): #check if tilelist can be deleted
  4472. tilemap = []
  4473. for i in range (0,max_map_size):
  4474. tilemap.append([])
  4475. a = 0
  4476. for b in range (0,max_map_size):
  4477. ran_num = random.randint(0,len(tl.tlist[tiles])-1)
  4478. tilemap[a].append(tl.tlist[tiles][ran_num])
  4479. b = 0
  4480. for a in range (1,max_map_size):
  4481. ran_num = random.randint(0,len(tl.tlist[tiles])-1)
  4482. tilemap[a].append(tl.tlist[tiles][ran_num])
  4483. for a in range (1,max_map_size):
  4484. for b in range (1,max_map_size):
  4485. ran_same = random.randint(0,9)
  4486. if ran_same < 5 :
  4487. tilemap[a].append(tilemap[a-1][b])
  4488. elif ran_same < 8:
  4489. tilemap[a].append(tilemap[a][b-1])
  4490. else:
  4491. ran_num = random.randint(0,len(tl.tlist[tiles])-1)
  4492. tilemap[a].append(tl.tlist[tiles][ran_num])
  4493. m = maP(name ,tilemap)
  4494. return m
  4495. def border_generator(self,layer,style='default'):
  4496. if style == 'default':
  4497. cave_name = 'local_0_0'
  4498. elif style == 'desert':
  4499. cave_name = 'desert_0_0'
  4500. m = self.default_map_generator(cave_name,'global_caves', tilelist)
  4501. m.map_type = 'border'
  4502. m.fill(tl.tlist['functional'][0])#fill with border
  4503. self.maplist[layer][cave_name] = m
  4504. def grot_generator(self,layer):
  4505. screen.render_load(15,1)
  4506. cave_name = 'dungeon_0_0'
  4507. m = self.default_map_generator(cave_name,'global_caves', tilelist)
  4508. m.map_type = 'grot'
  4509. m.set_music('grot','grot',True)
  4510. m.build_type = 'None'
  4511. m.fill(tl.tlist['global_caves'][3])#fill with hard rock
  4512. 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
  4513. m.set_frame(tl.tlist['functional'][0])
  4514. chance_ore = layer*5
  4515. chance_gem = layer*3
  4516. screen.render_load(15,10)
  4517. for y in range (0,max_map_size):
  4518. for x in range (0,max_map_size):
  4519. if m.tilemap[y][x].techID == tl.tlist['global_caves'][3].techID:#this is hard rock
  4520. replace = m.tilemap[y][x].replace
  4521. coin = random.randint(0,1)
  4522. percent = random.randint(1,100)
  4523. if coin == 0 and percent <= chance_ore:
  4524. m.tilemap[y][x] = tl.tlist['misc'][4]#set ore here
  4525. m.tilemap[y][x].replace = replace
  4526. elif coin == 1 and percent <= chance_gem:
  4527. m.tilemap[y][x] = tl.tlist['misc'][5]#set gem here
  4528. m.tilemap[y][x].replace = replace
  4529. screen.render_load(15,40)
  4530. for y in range (0,max_map_size):
  4531. for x in range (0,max_map_size):
  4532. if m.tilemap[y][x].techID == tl.tlist['misc'][1].techID:#this is mud
  4533. cent = random.randint(0,99)
  4534. if cent < 10: #its a chance of 10% that a blue mushroom spawns here
  4535. replace = m.tilemap[y][x]
  4536. m.tilemap[y][x] = tl.tlist['misc'][6]
  4537. m.tilemap[y][x].replace = replace
  4538. m.containers[y][x] = container([deepcopy(il.ilist['food'][1])])
  4539. screen.render_load(15,75)
  4540. num_lilys = int(((max_map_size*max_map_size)/100)*3)
  4541. for i in range (0,num_lilys):
  4542. pos = m.find_any(tl.tlist['misc'][0])#find low wather
  4543. try:
  4544. coin = random.randint(0,1)
  4545. if coin == 0:
  4546. m.tilemap[pos[1]][pos[0]] = tl.tlist['misc'][10]#set a water lily
  4547. else:
  4548. m.tilemap[pos[1]][pos[0]] = tl.tlist['misc'][14]#set a water lily with blossom
  4549. except:
  4550. None
  4551. screen.render_load(15,90)
  4552. pos = m.find_any(tl.tlist['misc'][0])#find any low water tile
  4553. m.tilemap[pos[1]][pos[0]] = tl.tlist['dungeon'][15]#set stair up
  4554. entrance_x = pos[0]
  4555. entrance_y = pos[1]
  4556. for sy in range(pos[1]-4,pos[1]+5):
  4557. for sx in range(pos[0]-4,pos[0]+5):
  4558. try:
  4559. if m.tilemap[sy][sx].move_group == 'soil':
  4560. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  4561. m.tilemap[sy][sx].move_group == 'dry_entrance'
  4562. elif m.tilemap[sy][sx].move_group == 'low_liquid':
  4563. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  4564. m.tilemap[sy][sx].move_group == 'wet_entrance'
  4565. except:
  4566. None
  4567. m.make_shops()
  4568. m.spawn_monsters(3)
  4569. screen.render_load(15,99)
  4570. self.maplist[layer][cave_name] = m
  4571. def elfish_generator(self,layer):
  4572. screen.render_load(16,1)
  4573. map_name = 'fortress_0_0'
  4574. m = self.default_map_generator(map_name,'global_caves', tilelist)
  4575. m.map_type = 'elfish_fortress'
  4576. m.set_music('elfish_fortress','elfish_fortress',True)
  4577. m.no_monster_respawn = True
  4578. m.build_type = 'None'
  4579. m.fill(tl.tlist['elfish'][0])
  4580. for y in range (10, max_map_size-10,10):
  4581. ran = random.randint(0,3)
  4582. for yy in range (y-1,y+2):
  4583. if ran < 3:
  4584. m.imp_connect((0,max_map_size-1),(yy,yy),tl.tlist['elfish'][1],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  4585. if ran < 3:
  4586. m.imp_connect((0,max_map_size-1),(y-2,y-2),tl.tlist['elfish'][3],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  4587. m.imp_connect((0,max_map_size-1),(y+2,y+2),tl.tlist['elfish'][3],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  4588. screen.render_load(16,10)
  4589. for x in range (10, max_map_size-10,10):
  4590. ran = random.randint(0,3)
  4591. for xx in range (x-1,x+2):
  4592. if ran < 3:
  4593. m.imp_connect((xx,xx),(0,max_map_size-1),tl.tlist['elfish'][1],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  4594. if ran < 3:
  4595. m.imp_connect((x-2,x-2),(0,max_map_size-1),tl.tlist['elfish'][3],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  4596. m.imp_connect((x+2,x+2),(0,max_map_size-1),tl.tlist['elfish'][3],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  4597. m.cut(5,max_map_size-6,5,max_map_size-6,tl.tlist['elfish'][3])
  4598. building_count = 0
  4599. run = True
  4600. screen.render_load(16,30)
  4601. while run:
  4602. pos=m.find_first(tl.tlist['elfish'][0])
  4603. if pos != False:
  4604. m.floating(pos[0],pos[1],tl.tlist['elfish'][5],tl.tlist['elfish'][3])#fill with help passive
  4605. building_count += 1
  4606. else:
  4607. run = False
  4608. m.exchange(tl.tlist['elfish'][5],tl.tlist['elfish'][0])
  4609. screen.render_load(16,50)
  4610. if building_count < 6:
  4611. return False #return false to make a loop if there are to less buildings inside the map
  4612. num_temples = int((float(building_count)/100)*10)
  4613. if num_temples == 0:
  4614. num_temples = 1
  4615. num_agriculture = int((float(building_count)/100)*10)
  4616. if num_agriculture == 0:
  4617. num_agriculture=1
  4618. num_meetingarea = int((float(building_count)/100)*10)
  4619. if num_meetingarea == 0:
  4620. num_meetingarea = 1
  4621. num_marketplace = int((float(building_count)/100)*10)
  4622. if num_marketplace == 0:
  4623. num_marketplace = 1
  4624. num_libaries = int((float(building_count)/100)*10)
  4625. if num_libaries == 0:
  4626. num_libaries = 1
  4627. num_dwellings = building_count-num_temples-num_agriculture-num_meetingarea-num_marketplace-num_libaries
  4628. screen.render_load(16,60)
  4629. m.cut(5,max_map_size-6,5,max_map_size-6,tl.tlist['elfish'][1])
  4630. for i in range(0,num_agriculture):
  4631. pos = m.find_any(tl.tlist['elfish'][0])#find any elfish_floor_indoor
  4632. m.floating(pos[0],pos[1],tl.tlist['elfish'][2],tl.tlist['elfish'][1])#replace this building with elfish_agriculture
  4633. for y in range(0,max_map_size,2):
  4634. for x in range(0,max_map_size):
  4635. if m.tilemap[y][x].techID == tl.tlist['elfish'][2].techID:#this is elfish agriculture
  4636. m.tilemap[y][x] = tl.tlist['misc'][0]#set low water
  4637. screen.render_load(16,65)
  4638. m.cut(5,max_map_size-6,5,max_map_size-6,tl.tlist['elfish'][3])
  4639. for i in range(0,num_marketplace):#set marketplaces
  4640. pos = m.find_any(tl.tlist['elfish'][0])#find any elfish_floor_indoor
  4641. m.floating(pos[0],pos[1],tl.tlist['elfish'][4],tl.tlist['elfish'][3])#fill this building with elfish_active
  4642. pos = m.find_first(tl.tlist['elfish'][4])
  4643. size = m.get_quarter_size(pos[0],pos[1])
  4644. for y in range(pos[1]+1,pos[1]+size[1]-1,2):
  4645. for x in range(pos[0]+1,pos[0]+size[0]-1,3):
  4646. m.npcs[y][x] = ml.mlist['shop'][0]
  4647. m.exchange(tl.tlist['elfish'][4],tl.tlist['shop'][0])
  4648. screen.render_load(16,70)
  4649. for i in range(0,num_temples):
  4650. pos = m.find_any(tl.tlist['elfish'][0])#find any elfish_floor_indoor
  4651. m.floating(pos[0],pos[1],tl.tlist['elfish'][4],tl.tlist['elfish'][3])#fill this building with elfish_active
  4652. pos = m.find_first(tl.tlist['elfish'][4])
  4653. size = m.get_quarter_size(pos[0],pos[1])
  4654. for y in range(pos[1],pos[1]+size[1],2):
  4655. for x in range(pos[0],pos[0]+size[0],2):
  4656. m.tilemap[y][x] = deepcopy(tl.tlist['functional'][22])
  4657. m.tilemap[y][x].replace = tl.tlist['elfish'][0]
  4658. m.tilemap[y][x].civilisation = False
  4659. m.tilemap[pos[1]+int(size[1]/2)][pos[0]+int(size[0]/2)] = deepcopy(tl.tlist['functional'][15])#set a altar
  4660. m.tilemap[pos[1]+int(size[1]/2)][pos[0]+int(size[0]/2)].replace = tl.tlist['elfish'][0]
  4661. m.tilemap[pos[1]+int(size[1]/2)][pos[0]+int(size[0]/2)].civilisation = False
  4662. m.exchange(tl.tlist['elfish'][4],tl.tlist['elfish'][5])
  4663. screen.render_load(16,75)
  4664. for i in range(0,num_meetingarea):
  4665. pos = m.find_any(tl.tlist['elfish'][0])
  4666. m.floating(pos[0],pos[1],tl.tlist['elfish'][4],tl.tlist['elfish'][3])#fill this building with elfish_active
  4667. pos = m.find_first(tl.tlist['elfish'][4])
  4668. size = m.get_quarter_size(pos[0],pos[1])
  4669. for y in range(pos[1]+2,pos[1]+size[1]-2):
  4670. for x in range(pos[0]+2,pos[0]+size[0]-1,4):
  4671. m.tilemap[y][x] = deepcopy(tl.tlist['functional'][16]) #set table
  4672. m.tilemap[y][x].replace = tl.tlist['elfish'][0]
  4673. m.tilemap[y][x].civilisation = False
  4674. for xx in range(x-1,x+2):
  4675. if m.tilemap[y][xx].techID == tl.tlist['elfish'][4].techID:
  4676. m.tilemap[y][xx] = deepcopy(tl.tlist['functional'][18])
  4677. m.tilemap[y][xx].replace = tl.tlist['elfish'][0]
  4678. m.tilemap[y][xx].civilisation = False
  4679. for yy in range(y-1,y+2):
  4680. if m.tilemap[yy][x].techID == tl.tlist['elfish'][4].techID:
  4681. m.tilemap[yy][x] = deepcopy(tl.tlist['functional'][18])
  4682. m.tilemap[yy][x].replace = tl.tlist['elfish'][0]
  4683. m.tilemap[yy][x].civilisation = False
  4684. m.exchange(tl.tlist['elfish'][4],tl.tlist['elfish'][5])
  4685. screen.render_load(16,80)
  4686. for i in range(0,num_libaries):
  4687. pos = m.find_any(tl.tlist['elfish'][0])
  4688. m.floating(pos[0],pos[1],tl.tlist['elfish'][4],tl.tlist['elfish'][3])#fill this building with elfish_active
  4689. pos = m.find_first(tl.tlist['elfish'][4])
  4690. size = m.get_quarter_size(pos[0],pos[1])
  4691. for y in range(pos[1]+1,pos[1]+size[1]-1,2):
  4692. for x in range(pos[0]+1,pos[0]+size[0]-1,2):
  4693. m.tilemap[y][x] = deepcopy(tl.tlist['functional'][19])
  4694. m.tilemap[y][x].civilisation = False
  4695. m.exchange(tl.tlist['elfish'][4],tl.tlist['elfish'][5])
  4696. screen.render_load(16,85)
  4697. for i in range(0,num_dwellings):
  4698. pos = m.find_any(tl.tlist['elfish'][0])
  4699. m.floating(pos[0],pos[1],tl.tlist['elfish'][4],tl.tlist['elfish'][3])#fill this building with elfish_active
  4700. pos = m.find_first(tl.tlist['elfish'][4])
  4701. pos_original = pos
  4702. size = m.get_quarter_size(pos[0],pos[1])
  4703. num_beds = int((size[0]*size[1])/9)
  4704. num_furniture = int((size[0]*size[1])/25)
  4705. for y in range(pos[1],pos[1]+size[1]):
  4706. for x in range(pos[0],pos[0]+size[0]):
  4707. m.tilemap[y][x] = tl.tlist['elfish'][5]
  4708. for y in range(pos[1]+1,pos[1]+size[1]-1):
  4709. for x in range(pos[0]+1,pos[0]+size[0]-1):
  4710. m.tilemap[y][x] = tl.tlist['elfish'][4]
  4711. for i in range(0,num_beds):#set beds
  4712. pos = m.find_any(tl.tlist['elfish'][4])
  4713. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['functional'][8])
  4714. m.tilemap[pos[1]][pos[0]].replace = deepcopy(tl.tlist['building'][9])
  4715. m.tilemap[pos[1]][pos[0]].civilisation = False
  4716. m.tilemap[pos[1]][pos[0]].replace.civilisation = False
  4717. for i in range(0,num_furniture):#set furnaces
  4718. pos = m.find_any(tl.tlist['elfish'][4])
  4719. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['functional'][14])
  4720. m.tilemap[pos[1]][pos[0]].replace = deepcopy(tl.tlist['building'][9])
  4721. m.tilemap[pos[1]][pos[0]].civilisation = False
  4722. m.tilemap[pos[1]][pos[0]].replace.civilisation = False
  4723. for i in range(0,num_furniture):#set wb's
  4724. pos = m.find_any(tl.tlist['elfish'][4])
  4725. ran = random.randint(9,13)
  4726. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['functional'][ran])
  4727. m.tilemap[pos[1]][pos[0]].replace = deepcopy(tl.tlist['building'][9])
  4728. m.tilemap[pos[1]][pos[0]].civilisation = False
  4729. m.tilemap[pos[1]][pos[0]].replace.civilisation = False
  4730. for y in range(pos_original[1]+1,pos_original[1]+size[1]-1):#set blue floor
  4731. for x in range(pos_original[0]+1,pos_original[0]+size[0]-1):
  4732. if m.tilemap[y][x].techID == tl.tlist['elfish'][4].techID:
  4733. m.tilemap[y][x] = deepcopy(tl.tlist['building'][9])
  4734. m.tilemap[y][x].civilisation = False
  4735. screen.render_load(16,90)
  4736. for yy in range(0,max_map_size,5):
  4737. for xx in range(0,max_map_size):
  4738. if m.tilemap[yy][xx].techID == tl.tlist['elfish'][3].techID:#this is elfish wall
  4739. m.tilemap[yy][xx] = deepcopy(tl.tlist['building'][2]) #set a open door here
  4740. m.tilemap[yy][xx].civilisation = False
  4741. for yyy in range(yy-1,yy+2):
  4742. for xxx in range(xx-1,xx+2):
  4743. if yyy >= 0 and xxx >= 0 and xxx < max_map_size and yyy < max_map_size:
  4744. 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:
  4745. #if a field next to a door isn't elfish_indoor, elfish_wall or shop_floor set it to elfish_indoor
  4746. m.tilemap[yyy][xxx] = tl.tlist['elfish'][0]
  4747. screen.render_load(16,95)
  4748. for yy in range(0,max_map_size):
  4749. for xx in range(0,max_map_size,5):
  4750. if m.tilemap[yy][xx].techID == tl.tlist['elfish'][3].techID:#this is elfish wall
  4751. m.tilemap[yy][xx] = deepcopy(tl.tlist['building'][2]) #set a open door here
  4752. m.tilemap[yy][xx].civilisation = False
  4753. for yyy in range(yy-1,yy+2):
  4754. for xxx in range(xx-1,xx+2):
  4755. if yyy >= 0 and xxx >= 0 and xxx < max_map_size and yyy < max_map_size:
  4756. 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:
  4757. #if a field next to a door isn't elfish_indoor, elfish_wall or shop_floor set it to elfish_indoor
  4758. m.tilemap[yyy][xxx] = tl.tlist['elfish'][0]
  4759. screen.render_load(16,97)
  4760. m.cut(5,max_map_size-6,5,max_map_size-6,tl.tlist['elfish'][3])
  4761. m.set_frame(tl.tlist['functional'][0])
  4762. #set fontains
  4763. for y in range(10,max_map_size-10,10):
  4764. for x in range(10,max_map_size-10,10):
  4765. if m.tilemap[y][x].techID == tl.tlist['elfish'][1].techID:
  4766. coin = random.randint(0,1)
  4767. if coin == 0:
  4768. m.tilemap[y][x] = deepcopy(tl.tlist['functional'][7])#set a fontain
  4769. m.tilemap[y][x].replace = tl.tlist['elfish'][1]
  4770. m.tilemap[y][x].civilisation = False #this is no players fontain
  4771. m.exchange(tl.tlist['elfish'][5],tl.tlist['elfish'][0])
  4772. pos = m.find_any(tl.tlist['functional'][7]) #set portal home
  4773. if pos == False:
  4774. pos = m.find_any(tl.tlist['elfish'][1])
  4775. replace = deepcopy(tl.tlist['elfish'][1])
  4776. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['portal'][2])
  4777. m.tilemap[pos[1]][pos[0]].replace = replace
  4778. m.spawn_monsters(6)
  4779. self.maplist[layer][map_name] = m
  4780. screen.render_load(16,00)
  4781. def mine_generator(self,layer):
  4782. screen.render_load(17,1)
  4783. cave_name = 'dungeon_0_0'
  4784. m = self.default_map_generator(cave_name,'global_caves', tilelist)
  4785. m.map_type = 'orcish_mines'
  4786. m.set_music('orcish_mines','orcish_mines',True)
  4787. m.build_type = 'None'
  4788. m.monster_plus = 9
  4789. screen.render_load(17,10)
  4790. m.fill(tl.tlist['mine'][1])#fill with mine wall
  4791. screen.render_load(17,30)
  4792. m.drunken_walker(int(max_map_size/2),int(max_map_size/2),tl.tlist['mine'][0],((max_map_size**2/100)*45))
  4793. screen.render_load(17,50)
  4794. screen.render_load(17,60)
  4795. m.exchange_when_surrounded(tl.tlist['mine'][1],tl.tlist['global_caves'][3],8) #only the outer tiles become mine wall
  4796. screen.render_load(17,70)
  4797. for y in range (0, max_map_size):
  4798. for x in range(0,max_map_size):
  4799. if m.tilemap[y][x].techID == tl.tlist['global_caves'][3].techID:#this is hard rock
  4800. ran = random.randint(0,99)
  4801. if ran > 69:
  4802. m.tilemap[y][x] = tl.tlist['misc'][4]#set ore
  4803. m.tilemap[y][x].replace = tl.tlist['global_caves'][0]
  4804. elif ran < 10:
  4805. m.tilemap[y][x] = tl.tlist['misc'][5]#set gem
  4806. m.tilemap[y][x].replace = tl.tlist['global_caves'][0]
  4807. screen.render_load(17,80)
  4808. m.set_frame(tl.tlist['functional'][0])
  4809. m.make_shops()
  4810. m.make_containers(15,30,tl.tlist['mine'][0],1,4,'remains')
  4811. num_moss = int(((max_map_size*max_map_size)/100)*3)
  4812. for i in range (0,num_moss):
  4813. pos = m.find_any(tl.tlist['mine'][0])#find mine floor
  4814. try:
  4815. m.tilemap[pos[1]][pos[0]] = tl.tlist['mine'][2]#set blood moss
  4816. except:
  4817. None
  4818. screen.render_load(17,90)
  4819. pos = m.find_any(tl.tlist['mine'][0])#find any mine floor tile
  4820. m.tilemap[pos[1]][pos[0]] = tl.tlist['dungeon'][17]#set stair up
  4821. entrance_x = pos[0]
  4822. entrance_y = pos[1]
  4823. for sy in range(pos[1]-4,pos[1]+5):
  4824. for sx in range(pos[0]-4,pos[0]+5):
  4825. try:
  4826. if m.tilemap[sy][sx].move_group == 'soil':
  4827. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  4828. m.tilemap[sy][sx].move_group == 'dry_entrance'
  4829. elif m.tilemap[sy][sx].move_group == 'low_liquid':
  4830. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  4831. m.tilemap[sy][sx].move_group == 'wet_entrance'
  4832. except:
  4833. None
  4834. m.spawn_monsters(9)
  4835. screen.render_load(17,99)
  4836. self.maplist[layer][cave_name] = m
  4837. def cave_generator(self, deep, style='default'):
  4838. if style == 'desert':
  4839. cave_name='desert_0_0'
  4840. else:
  4841. cave_name = 'local_0_0'
  4842. p = 9
  4843. for d in range(1,deep+2):
  4844. screen.render_load(4,p+(d*20))
  4845. m = self.default_map_generator(cave_name,'global_caves', tilelist)
  4846. if d < 4:
  4847. if style == 'desert':
  4848. m.map_type = 'desert_cave'
  4849. m.monster_plus = 7
  4850. else:
  4851. m.map_type = 'cave'
  4852. m.set_music('cave','cave',True)
  4853. else:
  4854. if style == 'desert':
  4855. m.map_type = 'desert_lava_cave'
  4856. m.monster_plus = 7
  4857. else:
  4858. m.map_type = 'lava_cave'
  4859. m.set_music('lava_cave','lava_cave',True)
  4860. m.thirst_multi_day = 2
  4861. m.thirst_multi_night = 2
  4862. if d > 3:
  4863. m.exchange(tl.tlist['global_caves'][4],tl.tlist['misc'][2])#exchange lava against hot cave ground
  4864. m.exchange(tl.tlist['global_caves'][1],tl.tlist['misc'][28])#exchange worn rock against obsidian
  4865. if d > 4:
  4866. m.exchange_when_surrounded(tl.tlist['misc'][2],tl.tlist['global_caves'][4],8)#make lava spots between hot cave ground
  4867. num = int((max_map_size*max_map_size)/(50*50))
  4868. for i in range(0,num):
  4869. ran = random.randint(0,1)
  4870. if ran > 0:
  4871. pos = m.find_any(tl.tlist['global_caves'][0]) #cave ground
  4872. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['functional'][23])# make master forges
  4873. else:
  4874. m.exchange(tl.tlist['global_caves'][4],tl.tlist['misc'][1])#exchange lava against mud
  4875. m.exchange_when_surrounded(tl.tlist['misc'][1],tl.tlist['misc'][0],8)#make low water spots between mud
  4876. #######set mushrooms, ore and gems
  4877. chance_ore = d
  4878. chance_gem = d/2
  4879. for y in range (0,max_map_size):
  4880. for x in range (0,max_map_size):
  4881. if m.tilemap[y][x].techID == tl.tlist['global_caves'][3].techID:#this is hard rock
  4882. replace = m.tilemap[y][x].replace
  4883. coin = random.randint(0,1)
  4884. percent = random.randint(1,100)
  4885. if coin == 0 and percent <= chance_ore:
  4886. m.tilemap[y][x] = tl.tlist['misc'][4]#set ore here
  4887. m.tilemap[y][x].replace = replace
  4888. elif coin == 1 and percent <= chance_gem:
  4889. m.tilemap[y][x] = tl.tlist['misc'][5]#set gem here
  4890. m.tilemap[y][x].replace = replace
  4891. if m.tilemap[y][x].techID == tl.tlist['misc'][1].techID:#this is mud
  4892. cent = random.randint(0,99)
  4893. if cent < 10: #its a chance of 10% that a blue mushroom spawns here
  4894. replace = m.tilemap[y][x]
  4895. m.tilemap[y][x] = tl.tlist['misc'][6]
  4896. m.tilemap[y][x].replace = replace
  4897. if m.tilemap[y][x].techID == tl.tlist['global_caves'][0].techID:#this is cave ground
  4898. cent = random.randint(0,99)
  4899. if cent < 10: #its a chance of 10% that a brown mushroom spawns here
  4900. replace = m.tilemap[y][x]
  4901. m.tilemap[y][x] = tl.tlist['misc'][7]
  4902. m.tilemap[y][x].replace = replace
  4903. elif cent < 15: #its a chance of 5% that a purple mushroom spawns here
  4904. replace = m.tilemap[y][x]
  4905. m.tilemap[y][x] = tl.tlist['misc'][8]
  4906. m.tilemap[y][x].replace = replace
  4907. m.set_frame(tl.tlist['functional'][0])
  4908. if d == 1 and style == 'default':#set stair up on lvl 1
  4909. pos = (int(max_map_size/2),int(max_map_size/2))
  4910. m.tilemap[pos[1]+1][pos[0]] = deepcopy(tl.tlist['functional'][2])#stair down
  4911. m.tilemap[pos[1]+1][pos[0]].damage = -1
  4912. m.tilemap[pos[1]+1][pos[0]].damage_mes = 'Your wounds are cured.'
  4913. m.tilemap[pos[1]+1][pos[0]].build_here = False
  4914. for yy in range(pos[1]-3,pos[1]+4):
  4915. for xx in range(pos[0]-3,pos[0]+4):
  4916. m.tilemap[yy][xx].no_spawn = True
  4917. for x in range(0,max_map_size):
  4918. if m.tilemap[x][pos[0]].techID == tl.tlist['global_caves'][3].techID:#this is hard rock
  4919. ran = random.randint(1,2)
  4920. m.tilemap[x][pos[0]] = deepcopy(tl.tlist['global_caves'][ran])
  4921. for y in range(0,max_map_size):
  4922. if m.tilemap[pos[1]+1][y].techID == tl.tlist['global_caves'][3].techID:#this is hard rock
  4923. ran = random.randint(1,2)
  4924. m.tilemap[pos[1]+1][y] = deepcopy(tl.tlist['global_caves'][ran])
  4925. #set vaults
  4926. for i in range(0,int(max_map_size**2/50**2)):
  4927. m.make_vault(tl.tlist['global_caves'][0],d)
  4928. #set grot/mine at lvl 1 and 3
  4929. if style == 'default':
  4930. if d == 1:
  4931. ran_pos = m.find_any(tl.tlist['global_caves'][0])
  4932. m.tilemap[ran_pos[1]][ran_pos[0]] = tl.tlist['dungeon'][14]
  4933. if style == 'desert':
  4934. if d == 3:
  4935. ran_pos = m.find_any(tl.tlist['global_caves'][0])
  4936. m.tilemap[ran_pos[1]][ran_pos[0]] = tl.tlist['dungeon'][16]
  4937. m.make_containers(1,2,tl.tlist['global_caves'][0],2,5,'chest')#set some chests
  4938. m.make_special_monsters(0,1,tl.tlist['global_caves'][0],d,'mimic')#maybe set some mimics
  4939. m.make_special_monsters(15,25,tl.tlist['global_caves'][0],d,'vase')#set some vases
  4940. if m.map_type == 'desert_lava_cave':
  4941. m.make_special_monsters(1,2,tl.tlist['global_caves'][0],d,'demonic chest')#maybe set some demonic chests
  4942. m.spawn_monsters(d)
  4943. if style == 'desert': #replace rock etc.
  4944. for y in range(0,max_map_size):
  4945. for x in range(0,max_map_size):
  4946. if m.tilemap[y][x].techID == tl.tlist['global_caves'][3].techID: #this is hard rock
  4947. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][24])
  4948. elif m.tilemap[y][x].techID == tl.tlist['global_caves'][1].techID: #this is worn rock
  4949. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][23])
  4950. elif m.tilemap[y][x].techID == tl.tlist['global_caves'][2].techID: #this is soft soil
  4951. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][23])
  4952. elif m.tilemap[y][x].techID == tl.tlist['misc'][4].techID: #this is ore
  4953. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][21])
  4954. elif m.tilemap[y][x].techID == tl.tlist['misc'][5].techID: #this is gem
  4955. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][22])
  4956. elif m.tilemap[y][x].techID == tl.tlist['misc'][7].techID: #this is a brown mushroom
  4957. replace = m.tilemap[y][x].replace
  4958. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][25])
  4959. m.tilemap[y][x].replace = replace
  4960. elif m.tilemap[y][x].techID == tl.tlist['misc'][8].techID: #this is a purple mushroom
  4961. replace = m.tilemap[y][x].replace
  4962. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][27])
  4963. m.tilemap[y][x].replace = replace
  4964. elif m.tilemap[y][x].techID == tl.tlist['misc'][6].techID: #this is a blue mushroom
  4965. replace = m.tilemap[y][x].replace
  4966. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][26])
  4967. m.tilemap[y][x].replace = replace
  4968. self.maplist[d][cave_name] = m
  4969. def grassland_generator(self,x,y,chance_scrubs, chance_trees, chance_herbs, number_rocks):
  4970. # chance_scrubs and chance_trees must be between 0 and 99
  4971. screen.render_load(3,1)
  4972. name = 'local_0_0'
  4973. helpmap = self.default_map_generator('1','help',tilelist)
  4974. tilemap = []
  4975. for a in range (0,max_map_size):
  4976. tilemap.append([])
  4977. for b in range (0,max_map_size):
  4978. tilemap[a].append(0)
  4979. m = maP(name,tilemap)
  4980. m.map_type = 'overworld'
  4981. m.set_music('overworld','night',True)
  4982. screen.render_load(3,2)
  4983. m.fill(tl.tlist['local'][0])#fill the map with grass
  4984. # set scrubs
  4985. for y in range (0,max_map_size):
  4986. for x in range (0,max_map_size):
  4987. if helpmap.tilemap[y][x].techID == tl.tlist['help'][0].techID: #<---scrub here
  4988. chance = random.randint(0,99)
  4989. if chance < chance_scrubs:
  4990. scrubs = (1,3,4,6,7,8,9)
  4991. coin = random.randint(0,len(scrubs)-1)
  4992. m.tilemap[y][x] = deepcopy(tl.tlist['local'][scrubs[coin]])
  4993. m.tilemap[y][x].replace = tl.tlist['local'][0]
  4994. screen.render_load(3,3)
  4995. #set trees
  4996. for y in range (0,max_map_size):
  4997. for x in range (0,max_map_size):
  4998. if helpmap.tilemap[y][x].techID == tl.tlist['help'][1].techID: #<---tree here
  4999. chance = random.randint(0,99)
  5000. if chance < chance_trees:
  5001. coin = random.randint(10,13)
  5002. m.tilemap[y][x] = tl.tlist['local'][coin]
  5003. m.tilemap[y][x].replace = tl.tlist['local'][0]#grass
  5004. screen.render_load(3,4)
  5005. #set herbs
  5006. for y in range (0,max_map_size):
  5007. for x in range (0,max_map_size):
  5008. if helpmap.tilemap[y][x].techID == tl.tlist['help'][0].techID: #<---scrub here
  5009. chance = random.randint(0,99)
  5010. if chance < chance_herbs:
  5011. coin = random.randint(15,16)
  5012. m.tilemap[y][x] = tl.tlist['local'][coin]
  5013. m.tilemap[y][x].replace = tl.tlist['local'][0]#grass
  5014. screen.render_load(3,5)
  5015. # set rocks
  5016. for n in range (0,number_rocks):
  5017. x = random.randint(0,max_map_size-1)
  5018. y = random.randint(0,max_map_size-1)
  5019. m.tilemap[y][x] = tl.tlist['local'][14]
  5020. m.tilemap[y][x].replace = tl.tlist['local'][0]#grass
  5021. screen.render_load(3,6)
  5022. #set water
  5023. for y in range (0,max_map_size):
  5024. for x in range (0,max_map_size):
  5025. if helpmap.tilemap[y][x].techID == tl.tlist['help'][2].techID: #<---water here
  5026. m.tilemap[y][x] = tl.tlist['misc'][0] # set low water here
  5027. screen.render_load(3,7)
  5028. m.exchange_when_surrounded(tl.tlist['misc'][0],tl.tlist['misc'][3],8) # exchange low wather against deep water
  5029. pos = (int(max_map_size/2),int(max_map_size/2))
  5030. m.set_sanctuary(pos[0],pos[1])
  5031. m.set_frame(tl.tlist['functional'][0])
  5032. screen.render_load(3,8)
  5033. #set desert portal
  5034. y = max_map_size -2
  5035. x = random.randint(2,max_map_size-2)
  5036. m.tilemap[y][x] = tl.tlist['portal'][3]
  5037. m.tilemap[y][x].replace = tl.tlist['local'][0]#grass
  5038. m.tilemap[y-1][x] = tl.tlist['local'][0]#grass
  5039. #set dungeon
  5040. ran_pos = m.find_any(tl.tlist['local'][0])
  5041. m.tilemap[ran_pos[1]][ran_pos[0]] = deepcopy(tl.tlist['dungeon'][7])
  5042. #set elfish portal
  5043. ran_pos = m.find_any(tl.tlist['local'][0])
  5044. replace = deepcopy(tl.tlist['local'][0])
  5045. m.tilemap[ran_pos[1]][ran_pos[0]] = deepcopy(tl.tlist['portal'][0])
  5046. m.tilemap[ran_pos[1]][ran_pos[0]].replace = replace
  5047. for q in range(0,int(max_map_size**2/50**2)*3):
  5048. m.make_orc_cave(tl.tlist['local'][0])#generate orc caves on grass
  5049. m.spawn_monsters(0)
  5050. self.maplist[0][name] = m
  5051. screen.render_load(3,9)
  5052. return pos
  5053. def shop_generator(self,style):
  5054. #0: Basic initializing
  5055. screen.render_load(19,0)
  5056. name = 'shop_0_0'
  5057. tilemap = []
  5058. for a in range (0,max_map_size):
  5059. tilemap.append([])
  5060. for b in range (0,max_map_size):
  5061. tilemap[a].append(0)
  5062. m = maP(name,tilemap)
  5063. m.map_type = style
  5064. m.build_type = 'None'
  5065. m.monster_plus = 0
  5066. m.monster_num = 0
  5067. m.set_music('shop','shop',True)
  5068. m.fill(tl.tlist['functional'][0])
  5069. screen.render_load(19,10)
  5070. center_x = int(max_map_size/2)
  5071. center_y = int(max_map_size/2)
  5072. for y in range(center_y-4,center_y+5):
  5073. for x in range(center_x-4,center_x+5):
  5074. m.tilemap[y][x] = deepcopy(tl.tlist['shop'][1])#wall
  5075. screen.render_load(19,20)
  5076. for y in range(center_y-3,center_y+4):
  5077. for x in range(center_x-3,center_x+4):
  5078. m.tilemap[y][x] = deepcopy(tl.tlist['dungeon'][1])#corridor
  5079. screen.render_load(19,30)
  5080. for y in range(center_y-2,center_y+3):
  5081. for x in range(center_x-2,center_x+3):
  5082. m.tilemap[y][x] = deepcopy(tl.tlist['shop'][1])#shop wall
  5083. screen.render_load(19,50)
  5084. for y in range(center_y-1,center_y+2):
  5085. for x in range(center_x-1,center_x+2):
  5086. m.tilemap[y][x] = deepcopy(tl.tlist['shop'][0])#shop floor
  5087. screen.render_load(19,70)
  5088. m.tilemap[center_y-2][center_x] = deepcopy(tl.tlist['shop'][2])#shop door
  5089. m.tilemap[center_y-3][center_x-1] = deepcopy(tl.tlist['shop'][5])#sign
  5090. m.tilemap[center_y-3][center_x-1].replace = deepcopy(tl.tlist['dungeon'][1])
  5091. m.tilemap[center_y-3][center_x].techID = -9999#nothing shall spawn here
  5092. m.tilemap[center_y-4][center_x] = deepcopy(tl.tlist['shop'][3])#shop exit
  5093. if style == 'pharmacy':
  5094. m.tilemap[center_y-3][center_x-1].move_mes = '[Naeria\'s Pharmacy]'
  5095. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][3])
  5096. elif style == 'pickaxe':
  5097. m.tilemap[center_y-3][center_x-1].move_mes = '[Eklor\'s Pickaxe Empire]'
  5098. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][4])
  5099. elif style == 'hardware':
  5100. m.tilemap[center_y-3][center_x-1].move_mes = '[Grimork\'s Hardware Store]'
  5101. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][5])
  5102. elif style == 'deco':
  5103. m.tilemap[center_y-3][center_x-1].move_mes = '[Larosa\'s Decoration Store]'
  5104. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][6])
  5105. elif style == 'book':
  5106. m.tilemap[center_y-3][center_x-1].move_mes = '[Xirazzzia\'s Bookshelf]'
  5107. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][7])
  5108. elif style == 'bomb':
  5109. m.tilemap[center_y-3][center_x-1].move_mes = '[Torguly\'s eXplozives Of al kinD]'
  5110. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][8])
  5111. elif style == 'general':
  5112. m.tilemap[center_y-3][center_x-1].move_mes = '[Arialu\'s General Store]'
  5113. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][9])
  5114. screen.render_load(19,90)
  5115. coin = random.randint(0,1)
  5116. if coin == 1:
  5117. pos = m.find_any(tl.tlist['dungeon'][1])
  5118. coin2 = random.randint(0,3)
  5119. if coin2 == 0:
  5120. replace = m.tilemap[pos[1]][pos[0]]
  5121. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['misc'][9])
  5122. m.tilemap[pos[1]][pos[0]].replace = replace
  5123. elif coin2 == 1:
  5124. replace = m.tilemap[pos[1]][pos[0]]
  5125. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['misc'][11])
  5126. m.tilemap[pos[1]][pos[0]].replace = replace
  5127. elif coin2 == 2:
  5128. m.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['cave'][2])
  5129. m.set_monster_strength(pos[0],pos[1],1)
  5130. else:
  5131. m.make_special_monsters(1,2,tl.tlist['dungeon'][1],1,'vase')
  5132. self.maplist[1][name] = m
  5133. screen.render_load(19,99)
  5134. def dungeon_generator(self,monster_plus,stair_down=True,num_traps=10,style='Dungeon'):#possible other style = 'Tomb'
  5135. #0: Basic initializing
  5136. screen.render_load(19,0)#Render progress bar 0%
  5137. if style == 'Tomb': #Set the graphics
  5138. tl.tlist['dungeon'][1].tile_pos = (4,6) #
  5139. tl.tlist['dungeon'][6].tile_pos = (4,7) #Sandstone walls,hidden doors and corridors for the acient tomb
  5140. tl.tlist['dungeon'][9].tile_pos = (4,7) #
  5141. else: #
  5142. tl.tlist['dungeon'][1].tile_pos = (10,6) #
  5143. tl.tlist['dungeon'][6].tile_pos = (2,6) #Default walls,hidden doors and corridors for the default dungeon
  5144. tl.tlist['dungeon'][9].tile_pos = (2,6) #
  5145. name = 'dungeon_0_0'#map name
  5146. tilemap = [] #Initializing a empty tilemap
  5147. for a in range (0,max_map_size): #
  5148. tilemap.append([]) #
  5149. for b in range (0,max_map_size): #
  5150. tilemap[a].append(0) #
  5151. m = maP(name,tilemap) #Generate a Map-object
  5152. if style == 'Tomb': #
  5153. m.map_type = 'tomb' #
  5154. m.set_music('tomb','tomb',True) #
  5155. else: #
  5156. m.map_type = 'dungeon' #and set a few constants for the new map
  5157. m.set_music('dungeon','dungeon',True)#
  5158. m.build_type = 'None' #
  5159. m.monster_plus = monster_plus #
  5160. m.monster_num = 0.3 #
  5161. m.no_monster_respawn = True #
  5162. m.fill(tl.tlist['dungeon'][9])#fill the map with dungeon wall tiles
  5163. screen.render_load(19,10)#Render progress bar 10%
  5164. #1: Set rooms
  5165. #Important fact: No matter how big the mapsize is set,
  5166. #dundeons only use the 52x52 tiles in the upper left connor.
  5167. #Thats as big as a small map.
  5168. test_build = True #Seperate the dungeon in a 3x3 grit.
  5169. while test_build: #Every part of the grit has a 66% chance to be a room
  5170. parts_with_rooms = [] #
  5171. #
  5172. for part_y in range(0,3): #
  5173. for part_x in range(0,3): #
  5174. ran = random.randint(0,9) #
  5175. if ran > 3: #
  5176. pick = (part_x,part_y) #
  5177. parts_with_rooms.append(pick) #
  5178. if len(parts_with_rooms) > 5: #every dungeon level needs at least 5 rooms
  5179. test_build = False #
  5180. coord_x = [] #transform the coordinates from the 3x3 grit into
  5181. coord_y = [] #real coordinates on the tilemap(center of the rooms)
  5182. #
  5183. for c in parts_with_rooms: #
  5184. x_offset = random.randint(0,5) #
  5185. y_offset = random.randint(0,5) #
  5186. #
  5187. real_x = 9+(15*c[0])+x_offset #
  5188. real_y = 9+(15*c[1])+y_offset #
  5189. #
  5190. coord_x.append(real_x) #
  5191. coord_y.append(real_y) #
  5192. 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
  5193. for i in range(0,len(coord_x)-1):#set variable roome size for all rooms
  5194. x_minus = random.randint(2,4)#
  5195. x_plus = random.randint(3,5) #
  5196. y_minus = random.randint(2,4)#
  5197. y_plus = random.randint(3,5) #
  5198. for yy in range(coord_y[i]-y_minus-1,coord_y[i]+y_plus+1): #draw walls around the rooms
  5199. for xx in range(coord_x[i]-x_minus-1,coord_x[i]+x_plus+1): #
  5200. m.tilemap[yy][xx] = deepcopy(tl.tlist['dungeon'][9]) #
  5201. for yy in range(coord_y[i]-y_minus,coord_y[i]+y_plus): #draw the room floor
  5202. for xx in range(coord_x[i]-x_minus,coord_x[i]+x_plus): #
  5203. m.tilemap[yy][xx] = tl.tlist['dungeon'][0] #
  5204. screen.render_load(19,25) #progress bar 25%
  5205. #2: Set doors
  5206. for yyy in range(0,52):
  5207. for xxx in range(0,52): #the 52 is hard scripted to safe performance
  5208. 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
  5209. if m.tilemap[yyy-1][xxx].move_group == 'soil' and m.tilemap[yyy+1][xxx].move_group == 'soil': #
  5210. m.tilemap[yyy][xxx] = tl.tlist['dungeon'][3] #
  5211. elif m.tilemap[yyy][xxx-1].move_group == 'soil' and m.tilemap[yyy][xxx+1].move_group == 'soil': #
  5212. m.tilemap[yyy][xxx] = tl.tlist['dungeon'][3] #
  5213. for yyy in range(0,52):
  5214. for xxx in range(0,52): #the 52 is hard scripted to safe performance
  5215. if m.tilemap[yyy][xxx].techID == tl.tlist['dungeon'][3].techID: #Remove all doors that are next to another door.
  5216. size = m.get_quarter_size(xxx,yyy) #Only spare one door per wall
  5217. if size[0] > 1: #
  5218. for rx in range(xxx,xxx+size[0]+1): #
  5219. m.tilemap[yyy][rx] = deepcopy(tl.tlist['dungeon'][9]) #
  5220. rrx = int(xxx+((rx-xxx)/2)) #
  5221. m.tilemap[yyy][rrx] = tl.tlist['dungeon'][3] #
  5222. #
  5223. if m.tilemap[yyy-1][rrx].move_group != 'soil': #
  5224. m.tilemap[yyy-1][rrx] = tl.tlist['dungeon'][1] #
  5225. if m.tilemap[yyy+1][rrx].move_group != 'soil': #
  5226. m.tilemap[yyy+1][rrx] = tl.tlist['dungeon'][1] #
  5227. #
  5228. if size[1] > 1: #
  5229. for ry in range(yyy,yyy+size[1]+1): #
  5230. m.tilemap[ry][xxx] = deepcopy(tl.tlist['dungeon'][9]) #
  5231. rry = int(yyy+((ry-yyy)/2)) #
  5232. m.tilemap[rry][xxx] = tl.tlist['dungeon'][3] #
  5233. #
  5234. if m.tilemap[rry][xxx-1].move_group != 'soil': #
  5235. m.tilemap[rry][xxx-1] = tl.tlist['dungeon'][1] #
  5236. if m.tilemap[rry][xxx+1].move_group != 'soil': #
  5237. m.tilemap[rry][xxx+1] = tl.tlist['dungeon'][1] #
  5238. screen.render_load(19,40)#Render progress bar 40%
  5239. test = deepcopy(m) #Make a copy of the map as is
  5240. pos = test.find_first(tl.tlist['dungeon'][0]) #and performe a float test,
  5241. test.floating(pos[0],pos[1],tl.tlist['misc'][0],tl.tlist['dungeon'][9]) #in order to find not conected parts.
  5242. screen.render_load(19,50) #Render progress bar 50%
  5243. for yyy in range(0,52): #Remove not connected parts
  5244. for xxx in range(0,52): #
  5245. if test.tilemap[yyy][xxx].techID != tl.tlist['dungeon'][9].techID and test.tilemap[yyy][xxx].techID != tl.tlist['misc'][0].techID: #
  5246. m.tilemap[yyy][xxx] = tl.tlist['dungeon'][9] #
  5247. screen.render_load(19,60)#Render progress bar 60%
  5248. for yyy in range(0,52): #Randomize doors:
  5249. for xxx in range(0,52): #-normal door
  5250. #-resisting door
  5251. if m.tilemap[yyy][xxx].techID == tl.tlist['dungeon'][3].techID: #-etc.
  5252. ran = random.randint(3,6) #
  5253. m.tilemap[yyy][xxx] = tl.tlist['dungeon'][ran] #
  5254. if m.tilemap[yyy][xxx].techID == tl.tlist['dungeon'][9].techID: #Randomize wall design
  5255. ran_test = random.randint(0,99) #
  5256. if ran_test > 75: #
  5257. if style == 'Dungeon': #
  5258. ran = random.randint(0,2) #
  5259. m.tilemap[yyy][xxx].tile_pos = (11,0+ran) #
  5260. if style == 'Tomb': #
  5261. ran = random.randint(0,2) #
  5262. m.tilemap[yyy][xxx].tile_pos = (12,0+ran) #
  5263. screen.render_load(19,70)#Render progress bar 70%
  5264. #3: Make stairs
  5265. stair_up_pos = m.find_any(tl.tlist['dungeon'][0]) #Set a up leading stair on any floor tile.
  5266. entrance_x = stair_up_pos[0] #
  5267. entrance_y = stair_up_pos[1] #
  5268. if style == 'Tomb': #
  5269. m.tilemap[stair_up_pos[1]][stair_up_pos[0]] = tl.tlist['dungeon'][19] #
  5270. else: #
  5271. m.tilemap[stair_up_pos[1]][stair_up_pos[0]] = tl.tlist['dungeon'][8] #
  5272. for sy in range(stair_up_pos[1]-4,stair_up_pos[1]+5):
  5273. for sx in range(stair_up_pos[0]-4,stair_up_pos[0]+5):
  5274. try:
  5275. if m.tilemap[sy][sx].move_group == 'soil':
  5276. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  5277. m.tilemap[sy][sx].move_group = 'dry_entrance'
  5278. elif m.tilemap[sy][sx].move_group == 'low_liquid':
  5279. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  5280. m.tilemap[sy][sx].move_group = 'wet_entrance'
  5281. except:
  5282. None
  5283. if stair_down == True: #If we are not on the deepest lvl:
  5284. stair_down_pos = m.find_any(tl.tlist['dungeon'][0]) #Set a down leading stair on any floor tile.
  5285. if style == 'Tomb': #
  5286. m.tilemap[stair_down_pos[1]][stair_down_pos[0]] = tl.tlist['dungeon'][18] #
  5287. else: #
  5288. m.tilemap[stair_down_pos[1]][stair_down_pos[0]] = tl.tlist['dungeon'][7] #
  5289. else: #Make a chest whit a reward on the deepest lvl instead
  5290. chest_pos = m.find_any(tl.tlist['dungeon'][0]) #
  5291. m.tilemap[chest_pos[1]][chest_pos[0]] = tl.tlist['dungeon'][20] #
  5292. m.tilemap[chest_pos[1]][chest_pos[0]].replace = tl.tlist['dungeon'][0] #
  5293. if style == 'Tomb':
  5294. 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
  5295. else: #
  5296. m.add_container([il.ilist['special_clothe'][1],il.ilist['misc'][33],il.ilist['misc'][41]],chest_pos[0],chest_pos[1])#
  5297. for h in range(0,len(ml.mlist['vip_cage'])): #set vip_cages
  5298. p = m.find_any(tl.tlist['dungeon'][0]) #
  5299. m.npcs[p[1]][p[0]] = deepcopy(ml.mlist['vip_cage'][h]) #
  5300. m.set_monster_strength(p[0],p[1],1,lvl_bonus = 9) #
  5301. screen.render_load(19,80)#Render progress bar 80%
  5302. #4: Make Traps
  5303. for i in range(0,num_traps): #Set hidden traps on random floor tiles.
  5304. pos = m.find_any(tl.tlist['dungeon'][0]) #
  5305. replace = m.tilemap[pos[1]][pos[0]] #
  5306. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['dungeon'][10]) #Traps have to be deepcopied to work proper.
  5307. m.tilemap[pos[1]][pos[0]].replace = replace #
  5308. screen.render_load(19,90) #Render Progress bar 90%
  5309. #5: Make interior
  5310. num_rooms = len(parts_with_rooms) #Make chests with random loot
  5311. m.make_containers(int(num_rooms/3),int(num_rooms/2),tl.tlist['dungeon'][0],1,3,'chest') #
  5312. for c in range(0,num_rooms): #Set random fontains on floor tiles
  5313. pos = m.find_any(tl.tlist['dungeon'][0]) #
  5314. ran = random.randint(0,99) #
  5315. if ran < 15: #
  5316. tile = deepcopy(tl.tlist['dungeon'][12]) #acid fontain
  5317. elif ran > 84: #
  5318. tile = deepcopy(tl.tlist['dungeon'][13]) #healing fontain
  5319. else: #
  5320. tile = deepcopy(tl.tlist['functional'][7]) #fontain
  5321. tile.civilisation = False #
  5322. tile.build_here = False #
  5323. tile.can_grown = False #
  5324. tile.replace = tl.tlist['dungeon'][0] #
  5325. m.tilemap[pos[1]][pos[0]] = tile #
  5326. coin = random.randint(0,1) #Set a Altar on 50% of all maps
  5327. if coin == 1: #that are generated with this function
  5328. pos = m.find_any(tl.tlist['dungeon'][0]) #
  5329. tile = deepcopy(tl.tlist['functional'][15]) #
  5330. tile.civilisation = False #
  5331. tile.build_here = False #
  5332. tile.can_grown = False #
  5333. tile.replace = tl.tlist['dungeon'][0] #
  5334. m.tilemap[pos[1]][pos[0]] = tile #
  5335. num_statue = random.randint(4,6) #generate random statues
  5336. for l in range(0,num_statue): #
  5337. kind = random.randint(0,len(tl.tlist['statue'])-1) #
  5338. pos = m.find_any(tl.tlist['dungeon'][0]) #
  5339. tile = deepcopy(tl.tlist['statue'][kind]) #
  5340. tile.replace = tl.tlist['dungeon'][0] #
  5341. m.tilemap[pos[1]][pos[0]] = tile #
  5342. num_deco = random.randint(8,10) #generate random deco
  5343. for l in range(0,num_deco): #
  5344. if style == 'Tomb': #
  5345. kind = random.randint(3,5) #
  5346. else: #
  5347. kind = random.randint(0,2) #
  5348. pos = m.find_any(tl.tlist['dungeon'][0]) #
  5349. tile = deepcopy(tl.tlist['deco'][kind]) #
  5350. tile.replace = tl.tlist['dungeon'][0] #
  5351. m.tilemap[pos[1]][pos[0]] = tile #
  5352. num_cage = random.randint(1,2) #spawn cages
  5353. for q in range(0,num_cage): #
  5354. pos = m.find_any(tl.tlist['dungeon'][0]) #
  5355. m.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['cage'][random.randint(0,len(ml.mlist['cage'])-1)]) #
  5356. m.set_monster_strength(pos[0],pos[1],1,lvl_bonus=9) #
  5357. m.spawn_monsters(0) #Spawn initial monsters
  5358. m.make_special_monsters(10,20,tl.tlist['dungeon'][0],m.monster_plus,'vase') #
  5359. m.make_special_monsters(1,2,tl.tlist['dungeon'][0],m.monster_plus,'mimic') #
  5360. if style == 'Tomb': #
  5361. m.make_special_monsters(1,3,tl.tlist['dungeon'][0],m.monster_plus,'demonic chest') #
  5362. coin = random.randint(0,1)
  5363. if coin == 1:
  5364. m.spawn_magic_shops()
  5365. self.maplist[1][name] = m # Add map to world.maplist
  5366. screen.render_load(19,99) #Render progress bar 99%
  5367. def desert_generator(self,chance_object):
  5368. #chance_objects must be between 0 and 99
  5369. screen.render_load(18,1)
  5370. name = 'desert_0_0'
  5371. tilemap = []
  5372. for a in range (0,max_map_size):
  5373. tilemap.append([])
  5374. for b in range (0,max_map_size):
  5375. tilemap[a].append(0)
  5376. m = maP(name,tilemap)
  5377. m.map_type = 'desert'
  5378. m.build_type = 'Full'
  5379. m.monster_plus = 7
  5380. m.thirst_multi_day = 2
  5381. m.set_music('desert','night',True)
  5382. m.fill(tl.tlist['extra'][0])
  5383. y_river = random.randint((17),(max_map_size-17))
  5384. river_offset = random.randint(-3,3)
  5385. plus = 0
  5386. minus = 0
  5387. screen.render_load(18,20)
  5388. for c in range (0,max_map_size):
  5389. for g in range (-2,7):
  5390. m.tilemap[y_river+river_offset+g][c] = tl.tlist['local'][0]#set grass
  5391. for w in range (0,5):
  5392. m.tilemap[y_river+river_offset+w][c] = tl.tlist['misc'][0]#set low water
  5393. if river_offset < 4:
  5394. plus = 1
  5395. else:
  5396. plus = 0
  5397. if river_offset > -4:
  5398. minus = -1
  5399. else:
  5400. minus = 0
  5401. offset_change = random.randint(minus,plus)
  5402. river_offset += offset_change
  5403. m.exchange_when_surrounded(tl.tlist['misc'][0],tl.tlist['misc'][3],7)
  5404. screen.render_load(18,40)
  5405. for b in range(2,max_map_size-2,10):
  5406. #north side of the river
  5407. building_offset =random.randint(0,4)
  5408. number_beds = 0
  5409. for y in range(y_river-12,y_river-7):
  5410. for x in range(b+building_offset,b+building_offset+5):
  5411. if x == b+building_offset or x == b+building_offset+4:
  5412. if y == y_river-10:
  5413. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][9])
  5414. else:
  5415. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][2])
  5416. elif y == y_river-12 or y == y_river-8:
  5417. if x == b+building_offset+2:
  5418. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][9])
  5419. else:
  5420. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][2])
  5421. else:
  5422. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][1])
  5423. if x == b+building_offset+1 or x == b+building_offset+3:
  5424. if y == y_river-11 or y == y_river-9:
  5425. obj_here = random.randint(0,2) #0: nothing, 1:bed 2:workbench
  5426. if number_beds == 0:
  5427. obj_here = 1
  5428. if obj_here != 0:
  5429. if obj_here == 1:
  5430. obj = ('functional',8)
  5431. number_beds += 1
  5432. else:
  5433. ran = random.randint(9,15)
  5434. obj = ('functional',ran)
  5435. m.tilemap[y][x] = deepcopy(tl.tlist[obj[0]][obj[1]])
  5436. m.tilemap[y][x].replace = deepcopy(tl.tlist['extra'][1])
  5437. m.tilemap[y][x].civilisation = False
  5438. m.tilemap[y][x].build_here = False
  5439. m.tilemap[y][x].move_group = 'house'
  5440. #south side of the river
  5441. building_offset = random.randint(0,4)
  5442. number_beds = 0
  5443. screen.render_load(18,60)
  5444. for y in range(y_river+8,y_river+13):
  5445. for x in range(b+building_offset,b+building_offset+5):
  5446. if x == b+building_offset or x == b+building_offset+4:
  5447. if y == y_river+10:
  5448. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][9])
  5449. else:
  5450. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][2])
  5451. elif y == y_river+12 or y == y_river+8:
  5452. if x == b+building_offset+2:
  5453. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][9])
  5454. else:
  5455. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][2])
  5456. else:
  5457. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][1])
  5458. if x == b+building_offset+1 or x == b+building_offset+3:
  5459. if y == y_river+9 or y == y_river+11:
  5460. obj_here = random.randint(0,2) #0: nothing, 1:bed 2:workbench
  5461. if number_beds == 0:
  5462. obj_here = 1
  5463. if obj_here != 0:
  5464. if obj_here == 1:
  5465. obj = ('functional',8)
  5466. number_beds += 1
  5467. else:
  5468. ran = random.randint(9,15)
  5469. obj = ('functional',ran)
  5470. m.tilemap[y][x] = deepcopy(tl.tlist[obj[0]][obj[1]])
  5471. m.tilemap[y][x].replace = deepcopy(tl.tlist['extra'][1])
  5472. m.tilemap[y][x].civilisation = False
  5473. m.tilemap[y][x].build_here = False
  5474. m.tilemap[y][x].move_group = 'house'
  5475. make_bridges = True
  5476. num_bridges = 0
  5477. num_bridges_max = ((max_map_size/50)*3)+1
  5478. screen.render_load(18,80)
  5479. while num_bridges < num_bridges_max:
  5480. x_pos = random.randint(5,max_map_size-5)
  5481. num_wall = 0
  5482. for test in range(0,max_map_size):
  5483. if m.tilemap[test][x_pos].techID == tl.tlist['extra'][2].techID:
  5484. num_wall += 1
  5485. if num_wall == 0:
  5486. num_bridges += 1
  5487. for y in range(0,max_map_size):
  5488. 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
  5489. replace = deepcopy(m.tilemap[y][x_pos])
  5490. m.tilemap[y][x_pos] = deepcopy(tl.tlist['extra'][8])
  5491. m.tilemap[y][x_pos].replace = replace
  5492. for y in range (0,max_map_size):
  5493. for x in range (0,max_map_size):
  5494. if m.tilemap[y][x].techID == tl.tlist['extra'][0].techID:
  5495. chance = random.randint(0,99)
  5496. if chance < chance_object:
  5497. obj_numbers = (3,4,5,14)
  5498. coin = random.randint(0,len(obj_numbers)-1)
  5499. m.tilemap[y][x] = tl.tlist['extra'][obj_numbers[coin]]
  5500. m.tilemap[y][x].replace = tl.tlist['extra'][0]#sand
  5501. elif m.tilemap[y][x].techID == tl.tlist['local'][0].techID:
  5502. chance = random.randint(0,99)
  5503. if chance < chance_object:
  5504. coin = random.randint(10,13)
  5505. m.tilemap[y][x] = tl.tlist['extra'][coin]
  5506. m.tilemap[y][x].replace = tl.tlist['local'][0]#grass
  5507. elif m.tilemap[y][x].techID == tl.tlist['extra'][9].techID:
  5508. for yy in range(y-1,y+2):
  5509. if m.tilemap[yy][x].replace != None:
  5510. m.tilemap[yy][x] = m.tilemap[yy][x].replace
  5511. for xx in range(x-1,x+2):
  5512. if m.tilemap[y][xx].replace != None:
  5513. m.tilemap[y][xx] = m.tilemap[y][xx].replace
  5514. if m.tilemap[y][x].techID == tl.tlist['functional'][8].techID:#bed
  5515. ran = random.randint(5,6)
  5516. m.npcs[y][x] = deepcopy(ml.mlist['special'][ran])
  5517. m.set_monster_strength(x,y,0)
  5518. m.set_frame(tl.tlist['functional'][0])
  5519. screen.render_load(18,99)
  5520. #set portal
  5521. y = 2
  5522. x = random.randint(2,max_map_size-2)
  5523. m.tilemap[y][x] = tl.tlist['portal'][5]
  5524. m.tilemap[y][x].replace = tl.tlist['extra'][0]#sand
  5525. m.tilemap[y+1][x] = tl.tlist['extra'][0]#sand
  5526. #set tomb
  5527. ran_pos = m.find_any(tl.tlist['extra'][0])
  5528. m.tilemap[ran_pos[1]][ran_pos[0]] = tl.tlist['dungeon'][18]
  5529. m.spawn_monsters(0)
  5530. self.maplist[0][name] = m
  5531. def choose_size(self):
  5532. #this is a all in one function with render, choose and set
  5533. global max_map_size # I know its no good style
  5534. run = True
  5535. mms = 52 #this is a temp variable that is used to store the worth for the max_map_size till this function is called
  5536. num = 0
  5537. while run:
  5538. #Part 1: Render
  5539. if low_res == False:
  5540. s = pygame.Surface((640,360))
  5541. else:
  5542. s = pygame.Surface((320,240))
  5543. bg = pygame.Surface((480,360))
  5544. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  5545. if low_res == True:
  5546. bg = pygame.transform.scale(bg,(320,240))
  5547. s.blit(bg,(0,0))
  5548. text = '~Choose Map-Size~ [Press ['+key_name['e']+'] to choose]'
  5549. text_image = screen.font.render(text,1,(255,255,255))
  5550. s.blit(text_image,(5,2))#menue title
  5551. entries = ('Small (50x50)', 'Medium (100x100)', 'Big (150x150)')
  5552. messages = ('Everything on a very small space.', 'Perfect size for the most players.', 'A big world.')
  5553. mapsizes = (52,102,152)
  5554. for i in range (0,3):
  5555. entry_image = screen.font.render(entries[i],1,(0,0,0))
  5556. if low_res == False:
  5557. s.blit(entry_image,(21,150+i*30))#blit menu_items
  5558. else:
  5559. s.blit(entry_image,(21,66+i*25))#blit menu_items
  5560. if low_res == False:
  5561. s.blit(gra_files.gdic['display'][4],(0,145+num*30))#blit marker
  5562. else:
  5563. s.blit(gra_files.gdic['display'][4],(0,58+num*25))#blit marker
  5564. entry_image = screen.font.render(messages[num],1,(255,255,255))
  5565. if low_res == True:
  5566. s.blit(entry_image,(2,225))
  5567. else:
  5568. s.blit(entry_image,(5,335))
  5569. if game_options.mousepad == 1 and low_res == False:
  5570. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  5571. else:
  5572. s_help = pygame.Surface((160,360))
  5573. s_help.fill((48,48,48))
  5574. s.blit(s_help,(480,0))
  5575. if game_options.mousepad == 0 and low_res == False:
  5576. s_help = pygame.Surface((640,360))
  5577. s_help.fill((48,48,48))
  5578. s_help.blit(s,(80,0))
  5579. s = s_help
  5580. if low_res == False:
  5581. s = pygame.transform.scale(s,(screen.displayx,screen.displayy))
  5582. screen.screen.blit(s,(0,0))
  5583. pygame.display.flip()
  5584. #Step 2: Choose
  5585. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  5586. if ui == 'w':
  5587. num -= 1
  5588. if num < 0:
  5589. num = 2
  5590. if ui == 's':
  5591. num += 1
  5592. if num > 2:
  5593. num = 0
  5594. if ui == 'e':
  5595. mms = mapsizes[num]
  5596. max_map_size = mms
  5597. self.map_size = mms
  5598. run = False
  5599. class mob():
  5600. def __init__(self, name, on_map, attribute, pos =[40,40,0],glob_pos=[0,0],build='Manual'):
  5601. self.name = name
  5602. self.on_map = on_map
  5603. self.attribute = attribute
  5604. self.lp = attribute.max_lp
  5605. self.mp = attribute.max_mp
  5606. self.pos = pos
  5607. self.glob_pos = glob_pos
  5608. self.last_map = 'Foo'
  5609. self.cur_map = 'Bar'
  5610. self.cur_z = self.pos[2]
  5611. self.last_z = 'Baz'
  5612. def move(self, x=0, y=0):
  5613. mc = self.move_check(x,y)
  5614. tile_move_group = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group
  5615. player_move_groups = ['soil','low_liquid','shop','house','wet_entrance','dry_entrance']
  5616. swim_check = True
  5617. for i in ('Head','Body','Legs','Feet'):
  5618. if player.inventory.wearing[i] != player.inventory.nothing:
  5619. swim_check = False
  5620. if swim_check == True:
  5621. player_move_groups.append('swim')
  5622. if player.buffs.hexed < 1:
  5623. player_move_groups.append('holy')
  5624. if self.buffs.immobilized > 0:
  5625. player_move_groups = ['not_existent_group1','not_existent_group2']
  5626. move_check2 = False
  5627. for j in player_move_groups:
  5628. if j == tile_move_group:
  5629. move_check2 = True
  5630. if mc == True:
  5631. if x > 0 and move_check2 == True and self.pos[0] < max_map_size - 1:
  5632. self.pos[0] += 1
  5633. if x < 0 and move_check2 == True and self.pos[0] > 0:
  5634. self.pos[0] -= 1
  5635. if y > 0 and move_check2 == True and self.pos[1] < max_map_size - 1:
  5636. self.pos[1] += 1
  5637. if y < 0 and move_check2 == True and self.pos[1] > 0:
  5638. self.pos[1] -= 1
  5639. self.stand_check()
  5640. def move_check(self,x,y):
  5641. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group == 'door':
  5642. 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:
  5643. #this is a resisting door or a hidden door
  5644. sfx.play('locked')
  5645. else:
  5646. sfx.play('open')
  5647. message.add(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_mes)
  5648. 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
  5649. return False
  5650. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group == 'shop_enter':
  5651. sfx.play('open')
  5652. screen.render_fade(True,False)
  5653. shop_types = ('pharmacy','pickaxe','hardware','deco','book','bomb','general')
  5654. ran = random.randint(0,len(shop_types)-1)
  5655. world.shop_generator(shop_types[ran])
  5656. self.save_pos=(self.pos[0],self.pos[1],self.pos[2],self.on_map)
  5657. 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
  5658. shop_pos = world.maplist[1]['shop_0_0'].find_first(tl.tlist['shop'][3])
  5659. self.pos[0] = shop_pos[0]
  5660. self.pos[1] = shop_pos[1]+1
  5661. self.pos[2] = 1
  5662. self.on_map = 'shop_0_0'
  5663. player.stand_check()
  5664. screen.render_fade(False,True)
  5665. return False
  5666. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group == 'shop_exit':
  5667. sfx.play('open')
  5668. self.pos[0] = self.save_pos[0]
  5669. self.pos[1] = self.save_pos[1]
  5670. self.pos[2] = self.save_pos[2]
  5671. self.on_map = self.save_pos[3]
  5672. player.stand_check()
  5673. screen.render_fade(False,True)
  5674. return False
  5675. try:
  5676. if world.maplist[self.pos[2]][self.on_map].npcs[self.pos[1]+y][self.pos[0]+x] != 0:
  5677. player.attack_monster(self.pos[0]+x,self.pos[1]+y)
  5678. return False
  5679. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].destroy != False: #for digging
  5680. 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
  5681. heated_stone = True
  5682. else:
  5683. heated_stone = False
  5684. if player.pos[2] > 3 and heated_stone == False:
  5685. brimstone = True
  5686. else:
  5687. brimstone = False
  5688. 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:
  5689. #this is not obsidian or soft soil
  5690. stone = True
  5691. else:
  5692. stone = False
  5693. 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:
  5694. if self == player:
  5695. message.add(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_mes)
  5696. 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
  5697. sfx.play('break')
  5698. try:
  5699. if self.skill.mining == 'Adept':
  5700. mat_addition = 2
  5701. elif self.skill.mining == 'Master':
  5702. mat_addition = 5
  5703. else:
  5704. mat_addition = 0
  5705. material = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].conected_resources[0]
  5706. mat_num = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].conected_resources[1] + mat_addition
  5707. mes = player.inventory.materials.add(material,mat_num)
  5708. message.add(mes)
  5709. if player.skill.mining != 'Master':
  5710. player.skill.mining_progress += 1
  5711. if player.skill.mining_progress == 200 and player.skill.mining != 'Adept':
  5712. player.skill.raise_skill('mining')
  5713. message.add('Your mining skill reaches adept level!')
  5714. sfx.play('lvl_up')
  5715. if player.skill.mining_progress == 1000 and player.skill.mining != 'Master':
  5716. player.skill.raise_skill('mining')
  5717. message.add('Your mining skill reaches master level!')
  5718. sfx.play('lvl_up')
  5719. except:
  5720. None
  5721. 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
  5722. world.maplist[self.pos[2]][self.on_map].countdowns.append(countdown('door', self.pos[0]+x, self.pos[1]+y,3))
  5723. sfx.play('open')
  5724. stone = False
  5725. heated_stone = False
  5726. brimstone = False
  5727. 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)
  5728. if heated_stone == True:#drop heated stone
  5729. ran = random.randint(0,99)
  5730. if ran < 5:
  5731. replace = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x]
  5732. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = deepcopy(tl.tlist['functional'][28])
  5733. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].replace = replace
  5734. elif brimstone == True:#drop brimstone
  5735. ran = random.randint(0,99)
  5736. if ran < 5:
  5737. replace = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x]
  5738. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = deepcopy(tl.tlist['functional'][29])
  5739. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].replace = replace
  5740. elif stone == True:#drop stone
  5741. ran = random.randint(0,99)
  5742. if ran < 5:
  5743. replace = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x]
  5744. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = deepcopy(tl.tlist['functional'][30])
  5745. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].replace = replace
  5746. if player.inventory.wearing['Pickaxe'] != player.inventory.nothing and world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].techID != tl.tlist['building'][3].techID:
  5747. player.inventory.wearing['Pickaxe'].take_damage()
  5748. if player.inventory.wearing['Pickaxe'].state > 0:
  5749. player.inventory.wearing['Pickaxe'].set_name()
  5750. else:
  5751. message.add('Your tool breaks into pieces.')
  5752. player.inventory.wearing['Pickaxe'] = player.inventory.nothing
  5753. sfx.play('item_break')
  5754. else:
  5755. if self == player:
  5756. message.add('You are unable to destroy this with the tool in your hand.')
  5757. return False
  5758. else:
  5759. None
  5760. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group == 'tree':
  5761. 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
  5762. apple = True
  5763. else:
  5764. apple = False
  5765. if player.inventory.wearing['Axe'] != player.inventory.nothing: #if player has a axe in his hand
  5766. chop_success = True
  5767. player.inventory.wearing['Axe'].take_damage()
  5768. if player.inventory.wearing['Axe'].state > 0:
  5769. player.inventory.wearing['Axe'].set_name()
  5770. else:
  5771. message.add('Your axe breaks into pieces.')
  5772. player.inventory.wearing['Axe'] = player.inventory.nothing
  5773. sfx.play('item_break')
  5774. else:
  5775. message.add('That hurts!')
  5776. player.lp -= 1
  5777. sfx.play('hit')
  5778. if random.randint(0,9) != 0: #90% to fail chopping down the wood with bare hands
  5779. chop_success = False
  5780. else:
  5781. chop_success = True
  5782. if chop_success == True:
  5783. if self.skill.woodcutting == 'Adept':
  5784. mat_addition = 2
  5785. elif self.skill.woodcutting == 'Master':
  5786. mat_addition = 5
  5787. else:
  5788. mat_addition = 0
  5789. material = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].conected_resources[0]
  5790. mat_num = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].conected_resources[1] + mat_addition
  5791. mes = player.inventory.materials.add(material,mat_num)
  5792. message.add(mes)
  5793. sfx.play('chop')
  5794. if player.skill.woodcutting != 'Master':
  5795. player.skill.woodcutting_progress += 1
  5796. if player.skill.woodcutting_progress == 200 and player.skill.woodcutting != 'Adept':
  5797. player.skill.raise_skill('woodcutting')
  5798. message.add('Your woodcutting skill reaches adept level!')
  5799. sfx.play('lvl_up')
  5800. if player.skill.woodcutting_progress == 1000 and player.skill.woodcutting != 'Master':
  5801. player.skill.raise_skill('woodcutting')
  5802. message.add('Your woodcutting skill reaches master level!')
  5803. sfx.play('lvl_up')
  5804. world.maplist[self.pos[2]][self.on_map].make_monsters_angry(self.pos[0],self.pos[1],'tree')
  5805. 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
  5806. if apple == True:
  5807. ran = random.randint(0,99)
  5808. if ran < 5:
  5809. ran2 = random.randint(0,99)
  5810. replace = deepcopy(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x])
  5811. if ran2 < 20:
  5812. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = deepcopy(tl.tlist['functional'][32])
  5813. else:
  5814. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = deepcopy(tl.tlist['functional'][31])
  5815. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].replace = replace
  5816. return False
  5817. if self.buffs.immobilized == 0:
  5818. 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':
  5819. sfx.play('walk_wet')
  5820. else:
  5821. sfx.play('walk_dry')
  5822. else:
  5823. sfx.play('immobilized')
  5824. return True
  5825. except:
  5826. None
  5827. def stand_check(self):
  5828. if self.on_map != 'shop_0_0':
  5829. if self.on_map != self.cur_map:
  5830. self.last_map = self.cur_map
  5831. self.cur_map = self.on_map
  5832. if self.pos[2] != self.cur_z:
  5833. self.last_z = self.cur_z
  5834. self.cur_z = self.pos[2]
  5835. world.maplist[self.pos[2]][self.on_map].special_check(self.pos[0],self.pos[1])
  5836. radius = 5
  5837. if player.pos[2] > 0:
  5838. radius = 2
  5839. elif player.pos[2] == 0:
  5840. if time.hour > 22 or time.hour < 4:
  5841. radius = 2
  5842. elif time.hour > 21 or time.hour < 5:
  5843. radius = 3
  5844. elif time.hour > 20 or time.hour < 6:
  5845. radius = 4
  5846. elif time.hour > 19 or time.hour < 7:
  5847. radius = 5
  5848. if player.buffs.light > 0 or player.buffs.nightvision > 0:
  5849. radius = 5
  5850. if player.buffs.blind > 0:
  5851. radius = 1
  5852. message.add(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].move_mes,True)
  5853. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].damage > 0 and player.buffs.fireresistance == 0:
  5854. self.lp = self.lp - world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].damage
  5855. if self == player:
  5856. try:
  5857. 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)')
  5858. except:
  5859. None
  5860. 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':
  5861. sfx_flame = False
  5862. body_list = ('Head','Body','Legs','Feet','Hold(R)','Hold(L)','Neck','Hand','Pickaxe','Axe')
  5863. for i in body_list:
  5864. if player.inventory.wearing[i] != player.inventory.nothing and player.inventory.wearing[i].material == 'wooden':
  5865. ran = random.randint(0,9)
  5866. if ran < 4:
  5867. message.add('Your '+player.inventory.wearing[i].name+' burns to ashes!')
  5868. player.inventory.wearing[i] = player.inventory.nothing
  5869. sfx_flame = True
  5870. if sfx_flame == True:
  5871. sfx.play('flame')
  5872. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].damage < 0:
  5873. if self.lp < self.attribute.max_lp:
  5874. self.lp = self.lp - world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].damage
  5875. luck = player.attribute.luck + player.inventory.wearing['Neck'].attribute.luck
  5876. for y in range(player.pos[1]-1,player.pos[1]+2):
  5877. for x in range(player.pos[0]-1,player.pos[0]+2):
  5878. if world.maplist[self.pos[2]][self.on_map].tilemap[y][x].techID == tl.tlist['dungeon'][6].techID:#this is a secret door
  5879. ran = random.randint(0,25)#check players luck
  5880. if ran < luck:
  5881. world.maplist[self.pos[2]][self.on_map].tilemap[y][x] = deepcopy(tl.tlist['dungeon'][3])
  5882. message.add('You notice a hidden door.')
  5883. screen.write_hit_matrix(player.pos[0],player.pos[1],14)
  5884. screen.write_hit_matrix(x,y,15)
  5885. sfx.play('found')
  5886. 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
  5887. ran = random.randint(0,25)#check players luck
  5888. if ran < luck:
  5889. world.maplist[self.pos[2]][self.on_map].tilemap[y][x].tile_pos = (10,8)
  5890. message.add('You notice a trap.')
  5891. screen.write_hit_matrix(player.pos[0],player.pos[1],14)
  5892. screen.write_hit_matrix(x,y,15)
  5893. sfx.play('found')
  5894. 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
  5895. ran = random.randint(0,15)#check players luck
  5896. if ran < luck:
  5897. world.maplist[self.pos[2]][self.on_map].tilemap[y][x].tile_pos = (12,11,12,12)
  5898. world.maplist[self.pos[2]][self.on_map].tilemap[y][x].use_group = 'dont_drink'
  5899. message.add('You notice a strange smell.')
  5900. screen.write_hit_matrix(player.pos[0],player.pos[1],14)
  5901. screen.write_hit_matrix(x,y,15)
  5902. sfx.play('found')
  5903. 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
  5904. ran = random.randint(0,15)#check players luck
  5905. if ran < luck:
  5906. world.maplist[self.pos[2]][self.on_map].tilemap[y][x].tile_pos = (11,11,11,12)
  5907. message.add('You notice a strange sparkle.')
  5908. screen.write_hit_matrix(player.pos[0],player.pos[1],14)
  5909. screen.write_hit_matrix(x,y,15)
  5910. sfx.play('found')
  5911. for y in range (-radius,radius+1):#line of sight
  5912. for x in range (-radius,radius+1):
  5913. try:
  5914. dist = ((x)**2+(y)**2)**0.5
  5915. if dist <= radius+1 or dist >= radius-1:
  5916. run = True
  5917. c = 0
  5918. while run:
  5919. try:
  5920. yy = ((y*c)/dist)
  5921. except:
  5922. yy = 1
  5923. try:
  5924. xx = ((x*c)/dist)
  5925. except:
  5926. xx = 1
  5927. view_x = int(xx) + self.pos[0]
  5928. view_y = int(yy) + self.pos[1]
  5929. world.maplist[self.pos[2]][self.on_map].known[view_y][view_x] = 1
  5930. if world.maplist[self.pos[2]][self.on_map].tilemap[view_y][view_x].transparency == True and c < radius:
  5931. c+=1
  5932. else:
  5933. run = False
  5934. except:
  5935. None
  5936. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].techID == tl.tlist['dungeon'][10].techID:
  5937. kind =random.randint(0,3)
  5938. position = deepcopy(player.pos)#copy player pos before the trap is triggered because teleport traps could change it
  5939. if kind == 0:#dart trap
  5940. ran = random.randint(0,25)
  5941. if ran < luck:
  5942. screen.write_hit_matrix(player.pos[0],player.pos[1],3)
  5943. message.add('A flying dagger miss you.')
  5944. sfx.play('miss')
  5945. else:
  5946. player.lp -= 3
  5947. screen.write_hit_matrix(player.pos[0],player.pos[1],4)
  5948. message.add('A flying dagger hits you.')
  5949. sfx.play('hit')
  5950. elif kind == 1:#teleport trap
  5951. t=world.maplist[self.pos[2]][self.on_map].find_all_moveable()
  5952. if len(t) > 0:
  5953. rt = []
  5954. for i in t:
  5955. if world.maplist[self.pos[2]][self.on_map].npcs[i[1]][i[0]] == 0:
  5956. rt.append((i[0],i[1]))
  5957. if len(rt) > 0:
  5958. screen.render_fade(True,False)
  5959. ran = random.randint(0,len(rt)-1)
  5960. player.pos[0] = rt[ran][0]
  5961. player.pos[1] = rt[ran][1]
  5962. screen.reset_hit_matrix()
  5963. message.add('You are teleported randomly.')
  5964. sfx.play('teleport')
  5965. player.stand_check()
  5966. screen.render_fade(False,True)
  5967. else:
  5968. message.add('Nothing seems to happen.')
  5969. sfx.play('throw')
  5970. elif kind == 2:#blinding trap
  5971. ran = random.randint(10,30)
  5972. player.buffs.set_buff('blind',ran)
  5973. message.add('A garish flash blinds you.')
  5974. elif kind == 3:#magic trap
  5975. player.mp = 0
  5976. screen.write_hit_matrix(player.pos[0],player.pos[1],7)
  5977. message.add('You loose your focus.')
  5978. replace = world.maplist[self.pos[2]][self.on_map].tilemap[position[1]][position[0]].replace
  5979. world.maplist[self.pos[2]][self.on_map].tilemap[position[1]][position[0]] = deepcopy(tl.tlist['dungeon'][11])
  5980. world.maplist[self.pos[2]][self.on_map].tilemap[position[1]][position[0]].replace = replace
  5981. if player.lp <= 0:
  5982. screen.render_dead()
  5983. self.lp = int(self.lp)
  5984. bgm.check_for_song()
  5985. if time.hour%2 == 0 and time.minute == 0:
  5986. help_player = deepcopy(player)
  5987. help_player.on_map = 'local_0_0'
  5988. help_player.pos[0] = max_map_size/2
  5989. help_player.pos[1] = max_map_size/2
  5990. help_player.pos[2] = 0
  5991. save(None,help_player,time,gods,save_path,os.sep)
  5992. def enter(self):
  5993. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'stair_down':
  5994. if world.maplist[self.pos[2]+1][self.on_map].tilemap[self.pos[1]][self.pos[0]].techID == tl.tlist['functional'][2].techID: #if there is a stair up below this
  5995. screen.render_fade(True,False)
  5996. player.pos[2] += 1
  5997. player.stand_check()#to unveil the surroundings
  5998. screen.render_fade(False,True)
  5999. else:
  6000. message.add('This stair seem to be blocked.')
  6001. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'stair_up': #this is a stair up
  6002. if world.maplist[self.pos[2]-1][self.on_map].tilemap[self.pos[1]][self.pos[0]].techID == tl.tlist['functional'][1].techID: #if there is a stair down above
  6003. screen.render_fade(True,False)
  6004. player.pos[2] -= 1
  6005. player.stand_check()#to unveil the surroundings
  6006. screen.render_fade(False,True)
  6007. else:
  6008. message.add('This stair seem to be blocked.')
  6009. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'drink':#this is a low wather or a fontain
  6010. #drink water
  6011. if player.attribute.thirst < player.attribute.thirst_max:
  6012. sfx.play('no_fish')
  6013. message.add('You take a sip of water.')
  6014. player.attribute.thirst += 240 #this is 1/3 of the water te player needs per day
  6015. if player.attribute.thirst > player.attribute.thirst_max:
  6016. player.attribute.thirst = player.attribute.thirst_max+1#the +1 is because the player will lose one point at the same round so you would get just 99%
  6017. else:
  6018. message.add('You are not thirsty right now.')
  6019. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'drink_acid':#this is a acid fontain
  6020. #drink acid water
  6021. if player.attribute.thirst < player.attribute.thirst_max:
  6022. message.add('You take a sip of water.')
  6023. player.lp -= 5
  6024. message.add('It hurts like acid.')
  6025. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].tile_pos = (12,11,12,12)
  6026. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group = 'dont_drink'
  6027. else:
  6028. message.add('You are not thirsty right now.')
  6029. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'dont_drink':
  6030. message.add('You shouldn\'t drink this water!')
  6031. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'drink_heal':#this is a healing fontain
  6032. #drink healing water
  6033. if player.attribute.thirst < player.attribute.thirst_max:
  6034. message.add('You take a sip of water.')
  6035. if player.lp < player.attribute.max_lp:
  6036. player.lp += 5
  6037. if player.lp > player.attribute.max_lp:
  6038. player.lp = player.attribute.max_lp
  6039. message.add('Your wounds are cured.')
  6040. replace = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace
  6041. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]] = deepcopy(tl.tlist['functional'][7])
  6042. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].civilisation = False
  6043. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].build_here = False
  6044. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].can_grown = False
  6045. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace = replace
  6046. else:
  6047. message.add('You are not thirsty right now.')
  6048. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'resource':
  6049. res = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_resources[0]
  6050. num = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_resources[1]
  6051. try:
  6052. conected_tile = (world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_tiles[0],world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_tiles[1])
  6053. except:
  6054. None
  6055. test = player.inventory.materials.add(res,num)
  6056. if test != 'Full!':
  6057. sfx.play('pickup')
  6058. message.add(test)
  6059. replace = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace
  6060. try:
  6061. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]] = deepcopy(tl.tlist[conected_tile[0]][conected_tile[1]])
  6062. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace = replace
  6063. except:
  6064. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]] = replace
  6065. else:
  6066. message.add(test)
  6067. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'sleep':#this is a bed
  6068. #sleep a bit
  6069. sleep = True
  6070. lp = player.lp
  6071. while sleep:
  6072. screen.render_load(12)
  6073. time.tick()
  6074. player.attribute.tiredness += 5
  6075. if player.buffs.adrenalised_max > 0:
  6076. player.buffs.adrenalised_max -= 5
  6077. if player.buffs.adrenalised_max < 0:
  6078. player.buffs.adrenalised_max = 0
  6079. if player.lp < lp:
  6080. message.add('You were hurt!')
  6081. sleep = False
  6082. if player.attribute.tiredness >= player.attribute.tiredness_max:#wake up because you've slept enough
  6083. player.attribute.tiredness = player.attribute.tiredness_max +1 #the +1 is because the player will lose one point at the same round so you would get just 99%
  6084. message.add('You feel refreshed.')
  6085. sleep = False
  6086. if int((player.attribute.hunger_max*100)/max(player.attribute.hunger,1)) < 11:
  6087. message.add('You feel hungry.')
  6088. sleep = False
  6089. if int((player.attribute.thirst_max*100)/max(player.attribute.thirst,1)) < 11:
  6090. message.add('You feel thirsty.')
  6091. sleep = False
  6092. monster_test = False
  6093. for y in range (player.pos[1]-1, player.pos[1]+2):#check for a monster
  6094. for x in range (player.pos[0]-1, player.pos[0]+2):
  6095. try:
  6096. if world.maplist[self.pos[2]][self.on_map].npcs[self.pos[1]][self.pos[0]] != 0:#<-------change this so that friendly npcs are ignored
  6097. monster_test = True
  6098. except:
  6099. None
  6100. if monster_test == True:#wake up because a monster borders the players sleep
  6101. message.add('You wake up with a sense of danger.')
  6102. sleep = False
  6103. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'gather':
  6104. help_container = container([world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_items])
  6105. item_name = help_container.items[0].name
  6106. test_loot = help_container.loot(0)
  6107. if test_loot == True:
  6108. sfx.play('pickup')
  6109. string = '+[' + item_name + ']'
  6110. message.add(string)
  6111. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]] = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace
  6112. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] = 0
  6113. else:
  6114. message.add('Your inventory is full!')
  6115. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'gather_scrub':
  6116. help_container = container([world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_items])
  6117. item_name = help_container.items[0].name
  6118. test_loot = help_container.loot(0)
  6119. if test_loot == True:
  6120. sfx.play('pickup')
  6121. string = '+[' + item_name + ']'
  6122. message.add(string)
  6123. cat = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_tiles[2][0]
  6124. num = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_tiles[2][1]
  6125. replace = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace
  6126. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]] = tl.tlist[cat][num]
  6127. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace = replace
  6128. else:
  6129. message.add('Your inventory is full!')
  6130. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'carpenter':
  6131. #this is a carpenter's workbench
  6132. run = True
  6133. first_call = True
  6134. while run:
  6135. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6136. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6137. screen.render_request('['+key_name['e']+'] - produce something (-10 Wood)', '['+key_name['b']+'] - take a produced item', '['+key_name['x']+'] - leave',first_call)
  6138. else:
  6139. screen.render_request('['+key_name['e']+'] - XXXXXXXXXXXX ', '['+key_name['b']+'] - take a produced item', '['+key_name['x']+'] - leave',first_call)
  6140. else:
  6141. screen.render_request('['+key_name['e']+'] - produce something (-10 Wood)', '['+key_name['b']+'] - pick up workbench', '['+key_name['x']+'] - leave',first_call)
  6142. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,0,mouse=game_options.mousepad)
  6143. first_call = False
  6144. if ui == 'exit':
  6145. exitgame = True
  6146. screen.render_load(5)
  6147. save(world,player,time,gods,save_path,os.sep)
  6148. screen.save_tmp_png()
  6149. master_loop = False
  6150. playing = False
  6151. run = False
  6152. return('exit')
  6153. if ui == 'e':
  6154. test = False
  6155. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6156. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6157. test = True
  6158. else:
  6159. test = True
  6160. if test == True:
  6161. if player.inventory.materials.wood >= 10:
  6162. gc = screen.get_choice('What do you want to produce?', ('Carpenter\'s Workbench', 'Carver\'s Workbench', 'Stonecuter\'s Workbench', 'Forger\'s Workbench', 'Alchemist\'s Workshop', 'Furniture'),True)
  6163. if gc == 'Break':
  6164. run = False
  6165. elif gc < 5:# give the chosen workbench to the player
  6166. items = (il.ilist['misc'][3],il.ilist['misc'][4],il.ilist['misc'][5],il.ilist['misc'][6],il.ilist['misc'][7])
  6167. choose = gc
  6168. elif gc == 5:
  6169. items = (il.ilist['misc'][1], il.ilist['misc'][2],il.ilist['misc'][10],il.ilist['misc'][11],il.ilist['misc'][68],il.ilist['misc'][13])
  6170. #chest, bed, table, w. seat, bookshelf
  6171. gc2 = screen.get_choice('What do you want to produce exactly?', ('Chest', 'Bed', 'Table', 'Seat', 'Throne', 'Bookshelf'),True)
  6172. choose = gc2
  6173. try:
  6174. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] == 0:
  6175. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] = container([items[choose]],False)
  6176. else:
  6177. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items.append(items[choose])
  6178. sfx.play('craft')
  6179. message_string = 'You produced a ' + items[choose].name + '.'
  6180. message.add(message_string)
  6181. player.inventory.materials.wood -= 10
  6182. except:
  6183. None
  6184. run = False
  6185. else:
  6186. message.add('You do not have enough wood!')
  6187. run = False
  6188. elif ui == 'b':
  6189. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6190. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].inventory(False)
  6191. run = False
  6192. else:
  6193. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace.techID != tl.tlist['sanctuary'][0].techID:
  6194. #this wb dosen't stand inside the sanctuary
  6195. helpc = container([il.ilist['misc'][3]],True)
  6196. item_name = helpc.items[0].name
  6197. test_loot = helpc.loot(0)
  6198. run = False
  6199. if test_loot == True:
  6200. sfx.play('pickup')
  6201. string = '+[' + item_name + ']'
  6202. message.add(string)
  6203. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]] = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace
  6204. else:
  6205. message.add('This workbench seems to be attached to the floor.')
  6206. run = False
  6207. elif ui == 'x':
  6208. run = False
  6209. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'carver':
  6210. #this is a carvers's workbench
  6211. run = True
  6212. first_call = True
  6213. while run:
  6214. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6215. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6216. screen.render_request('['+key_name['e']+'] - produce something (-5 Wood)', '['+key_name['b']+'] - take a produced item', '['+key_name['x']+'] - leave',first_call)
  6217. else:
  6218. screen.render_request('['+key_name['e']+'] - XXXXXXXXXXXX ', '['+key_name['b']+'] - take a produced item', '['+key_name['x']+'] - leave',first_call)
  6219. else:
  6220. screen.render_request('['+key_name['e']+'] - produce something (-5 Wood)', '['+key_name['b']+'] - pick up workbench', '['+key_name['x']+'] - leave',first_call)
  6221. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,0,mouse=game_options.mousepad)
  6222. first_call = False
  6223. if ui == 'exit':
  6224. exitgame = True
  6225. screen.render_load(5)
  6226. save(world,player,time,gods,save_path,os.sep)
  6227. screen.save_tmp_png()
  6228. master_loop = False
  6229. playing = False
  6230. run = False
  6231. return('exit')
  6232. if ui == 'e':
  6233. test = False
  6234. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6235. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6236. test = True
  6237. else:
  6238. test = True
  6239. if test == True:
  6240. if player.inventory.materials.wood >= 5:
  6241. final_choice = 'Foo'
  6242. gc = screen.get_choice('What do you want to prodcuce?', ('Tool', 'Weapon', 'Armor','Jewelry'), True)
  6243. if gc == 0: #make a tool
  6244. items = (il.ilist['misc'][44], item_wear('axe',0,0), item_wear('pickaxe',0,0),il.ilist['misc'][14])
  6245. final_choice = screen.get_choice('What do you want to prodcuce exactly?', ('Torch','Axe','Pickaxe','Fishing rod'),True)
  6246. elif gc == 1: #make a weapon
  6247. items = (item_wear('spear',0,0), item_wear('sword',0,0), item_wear('hammer',0,0), item_wear('rune',0,0), item_wear('wand',0,0), item_wear('rune staff',0,0), item_wear('artefact',0,0))
  6248. class_choice = screen.get_choice('What do you want to prodcuce exactly?', ('Melee Weapon','Magic Weapon'), True)
  6249. if class_choice == 0:
  6250. ran = random.randint(0,99)
  6251. if player.skill.weapon_crafting == 'Novice':
  6252. if ran < 90:
  6253. final_choice = 0
  6254. else:
  6255. finnal_choice = 1
  6256. elif player.skill.weapon_crafting == 'Adept':
  6257. if ran < 10:
  6258. final_choice = 0
  6259. elif ran < 90:
  6260. final_choice = 1
  6261. else:
  6262. final_choice = 2
  6263. elif player.skill.weapon_crafting == 'Master':
  6264. if ran < 5:
  6265. final_choice = 0
  6266. elif ran < 15:
  6267. final_choice = 1
  6268. else:
  6269. final_choice = 2
  6270. else:
  6271. ran = random.randint(0,99)
  6272. if player.skill.weapon_crafting == 'Novice':
  6273. if ran < 90:
  6274. final_choice = 3
  6275. else:
  6276. finnal_choice = 4
  6277. elif player.skill.weapon_crafting == 'Adept':
  6278. if ran < 10:
  6279. final_choice = 3
  6280. elif ran < 90:
  6281. final_choice = 4
  6282. else:
  6283. final_choice = 5
  6284. elif player.skill.weapon_crafting == 'Master':
  6285. if ran < 5:
  6286. final_choice = 3
  6287. elif ran < 15:
  6288. final_choice = 4
  6289. else:
  6290. final_choice = 5
  6291. elif gc == 2: #make some armor
  6292. items = (item_wear('shoes',0,0), item_wear('cuisse',0,0), item_wear('helmet',0,0), item_wear('armor',0,0))
  6293. final_choice = screen.get_choice('What do you want to prodcuce exactly?', ('Shoes','Cuisse','Helmet','Armor'), True)
  6294. elif gc == 3:#make some jewlry
  6295. items = (item_wear('ring',0,0), item_wear('amulet',0,0), item_wear('necklace',0,0), item_wear('talisman',0,0))
  6296. final_choice = screen.get_choice('What do you want to prodcuce exactly?', ('Ring','Amulet','Necklace','Talisman'), True)
  6297. choose = final_choice
  6298. try:
  6299. if choose != 'Foo':
  6300. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] == 0:
  6301. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] = container([items[choose]],False)
  6302. else:
  6303. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items.append(items[choose])
  6304. sfx.play('craft')
  6305. message_string = 'You produced a ' + items[choose].name + '.'
  6306. message.add(message_string)
  6307. if choose != 'Foo':
  6308. player.inventory.materials.wood -= 5
  6309. except:
  6310. None
  6311. run = False
  6312. else:
  6313. message.add('You do not have enough wood!')
  6314. run = False
  6315. elif ui == 'b':
  6316. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6317. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].inventory(False)
  6318. run = False
  6319. else:
  6320. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace.techID != tl.tlist['sanctuary'][0].techID:
  6321. #this wb dosen't stand inside the sanctuary
  6322. helpc = container([il.ilist['misc'][4]],True)
  6323. item_name = helpc.items[0].name
  6324. test_loot = helpc.loot(0)
  6325. run = False
  6326. if test_loot == True:
  6327. sfx.play('pickup')
  6328. string = '+[' + item_name + ']'
  6329. message.add(string)
  6330. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]] = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace
  6331. else:
  6332. message.add('This workbench seems to be attached to the floor.')
  6333. run = False
  6334. elif ui == 'x':
  6335. run = False
  6336. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'stonecutter':
  6337. #this is a stonecutter's workbench
  6338. run = True
  6339. first_call = True
  6340. while run:
  6341. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6342. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6343. screen.render_request('['+key_name['e']+'] - produce something (-10 Stone)', '['+key_name['b']+'] - take a produced item', '['+key_name['x']+'] - leave',first_call)
  6344. else:
  6345. screen.render_request('['+key_name['e']+'] - XXXXXXXXXXXX ', '['+key_name['b']+'] - take a produced item', '['+key_name['x']+'] - leave',first_call)
  6346. else:
  6347. screen.render_request('['+key_name['e']+'] - produce something (-10 Stone)', '['+key_name['b']+'] - pick up workbench', '['+key_name['x']+'] - leave',first_call)
  6348. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,0,mouse=game_options.mousepad)
  6349. first_call = False
  6350. if ui == 'exit':
  6351. exitgame = True
  6352. screen.render_load(5)
  6353. save(world,player,time,gods,save_path,os.sep)
  6354. screen.save_tmp_png()
  6355. master_loop = False
  6356. playing = False
  6357. run = False
  6358. return('exit')
  6359. if ui == 'e':
  6360. test = False
  6361. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6362. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6363. test = True
  6364. else:
  6365. test = True
  6366. if test == True:
  6367. if player.inventory.materials.stone >= 10:
  6368. gc = screen.get_choice('What do you want to produce?' ,('Functional Things', 'Decorative Things'), True)
  6369. if gc == 0: #make something functional
  6370. items = (il.ilist['misc'][0], il.ilist['misc'][8], il.ilist['misc'][9])
  6371. #items: fontain, furnace, altar
  6372. gc2 = screen.get_choice('What do you want to produce exactly?' ,('Fountain','Furnace','Altar'), True)
  6373. else:#make something decorative
  6374. items = (il.ilist['misc'][12],il.ilist['misc'][21],il.ilist['misc'][69])
  6375. #items: stone seat, pilar, throne
  6376. gc2 = screen.get_choice('What do you want to produce?' ,('Seat','Pilar','Throne'), True)
  6377. choose = gc2
  6378. try:
  6379. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] == 0:
  6380. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] = container([items[choose]],False)
  6381. else:
  6382. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items.append(items[choose])
  6383. sfx.play('craft')
  6384. message_string = 'You produced a ' + items[choose].name + '.'
  6385. message.add(message_string)
  6386. player.inventory.materials.stone -= 10
  6387. except:
  6388. None
  6389. run = False
  6390. else:
  6391. message.add('You do not have enough Stone!')
  6392. run = False
  6393. elif ui == 'b':
  6394. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6395. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].inventory(False)
  6396. run = False
  6397. else:
  6398. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace.techID != tl.tlist['sanctuary'][0].techID:
  6399. #this wb dosen't stand inside the sanctuary
  6400. helpc = container([il.ilist['misc'][5]],True)
  6401. item_name = helpc.items[0].name
  6402. test_loot = helpc.loot(0)
  6403. run = False
  6404. if test_loot == True:
  6405. sfx.play('pickup')
  6406. string = '+[' + item_name + ']'
  6407. message.add(string)
  6408. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]] = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace
  6409. else:
  6410. message.add('This workbench seems to be attached to the floor.')
  6411. run = False
  6412. elif ui == 'x':
  6413. run = False
  6414. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'forger' or world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'masterforge':
  6415. #this is a forger's workbench or a master forge
  6416. run = True
  6417. first_call = True
  6418. while run:
  6419. price = 5
  6420. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].techID == tl.tlist['functional'][23].techID: #this is a master forge
  6421. price = 15
  6422. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6423. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6424. string = ('['+key_name['e']+'] - produce something (-' + str(price) + ' Ore)', '['+key_name['b']+'] - take a produced item', '['+key_name['x']+'] - leave',first_call)
  6425. screen.render_request(string[0],string[1],string[2])
  6426. else:
  6427. screen.render_request('['+key_name['e']+'] - XXXXXXXXXXXX ', '['+key_name['b']+'] - take a produced item', '['+key_name['x']+'] - leave',first_call)
  6428. else:
  6429. string = '['+key_name['e']+'] - produce something (-' + str(price) + ' Ore)', '['+key_name['b']+'] - pick up workbench', '['+key_name['x']+'] - leave'
  6430. screen.render_request(string[0],string[1],string[2],first_call)
  6431. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,0,mouse=game_options.mousepad)
  6432. first_call = False
  6433. if ui == 'exit':
  6434. exitgame = True
  6435. screen.render_load(5)
  6436. save(world,player,time,gods,save_path,os.sep)
  6437. screen.save_tmp_png()
  6438. master_loop = False
  6439. playing = False
  6440. run = False
  6441. return('exit')
  6442. if ui == 'e':
  6443. test = False
  6444. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6445. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6446. test = True
  6447. else:
  6448. test = True
  6449. if test == True:
  6450. if player.inventory.materials.ore >= price:
  6451. if player.skill.metallurgy == 'Novice':
  6452. material = random.randint(6,11)#tin to bronze
  6453. elif player.skill.metallurgy == 'Adept':
  6454. material = random.randint(11,18)#bronze to titan
  6455. elif player.skill.metallurgy == 'Master':
  6456. material = random.randint(18,20)#titan to magnicum
  6457. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].techID == tl.tlist['functional'][23].techID: #this is a master forge
  6458. material = 20 #magnicum only
  6459. final_choice = 'Foo'
  6460. gc = screen.get_choice('What do you want to procuce?', ('Tool', 'Weapon', 'Armor','Jewelry'), True)
  6461. if gc == 0: #make a tool
  6462. final_choice = screen.get_choice('What do you want to procuce exactly?', ('Axe', 'Pickaxe'), True)
  6463. items = (item_wear('axe',material,0), item_wear('pickaxe',material,0))
  6464. elif gc == 1: #make a weapon
  6465. items = (item_wear('spear',material,0), item_wear('sword',material,0), item_wear('hammer',material,0), item_wear('wand',material,0), item_wear('rune',material,0), item_wear('rune staff',material,0), item_wear('artefact',material,0))
  6466. class_choice = screen.get_choice('What do you want to prodcuce?', ('Melee Weapon','Magic Weapon'), True)
  6467. if class_choice == 0:
  6468. ran = random.randint(0,99)
  6469. if player.skill.weapon_crafting == 'Novice':
  6470. if ran < 90:
  6471. final_choice = 0
  6472. else:
  6473. finnal_choice = 1
  6474. elif player.skill.weapon_crafting == 'Adept':
  6475. if ran < 10:
  6476. final_choice = 0
  6477. elif ran < 90:
  6478. final_choice = 1
  6479. else:
  6480. final_choice = 2
  6481. elif player.skill.weapon_crafting == 'Master':
  6482. if ran < 5:
  6483. final_choice = 0
  6484. elif ran < 15:
  6485. final_choice = 1
  6486. else:
  6487. final_choice = 2
  6488. else:
  6489. ran = random.randint(0,99)
  6490. if player.skill.weapon_crafting == 'Novice':
  6491. if ran < 90:
  6492. final_choice = 3
  6493. else:
  6494. finnal_choice = 4
  6495. elif player.skill.weapon_crafting == 'Adept':
  6496. if ran < 10:
  6497. final_choice = 3
  6498. elif ran < 90:
  6499. final_choice = 4
  6500. else:
  6501. final_choice = 5
  6502. elif player.skill.weapon_crafting == 'Master':
  6503. if ran < 5:
  6504. final_choice = 3
  6505. elif ran < 15:
  6506. final_choice = 4
  6507. else:
  6508. final_choice = 5
  6509. elif gc == 2: #make some armor
  6510. final_choice = screen.get_choice('What do you want to procuce exactly?', ('Shoes', 'Cuisse', 'Helmet', 'Armor'), True)
  6511. items = (item_wear('shoes',material,0), item_wear('cuisse',material,0), item_wear('helmet',material,0), item_wear('armor',material,0))
  6512. elif gc == 3:#make some jewelry
  6513. items = (item_wear('ring',material,0), item_wear('amulet',material,0), item_wear('necklace',material,0), item_wear('talisman',material,0))
  6514. final_choice = screen.get_choice('What do you want to prodcuce?', ('Ring','Amulet','Necklace','Talisman'), True)
  6515. choose = final_choice
  6516. try:
  6517. if choose != 'Foo':
  6518. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] == 0:
  6519. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] = container([items[choose]],False)
  6520. else:
  6521. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items.append(items[choose])
  6522. sfx.play('craft')
  6523. message_string = 'You produced a ' + items[choose].name + '.'
  6524. message.add(message_string)
  6525. if choose != 'Foo':
  6526. player.inventory.materials.ore -= price
  6527. except:
  6528. None
  6529. run = False
  6530. else:
  6531. message.add('You do not have enough ore!')
  6532. run = False
  6533. elif ui == 'b':
  6534. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6535. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].inventory(False)
  6536. run = False
  6537. else:
  6538. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace.techID != tl.tlist['sanctuary'][0].techID:
  6539. #this wb dosen't stand inside the sanctuary
  6540. helpc = container([il.ilist['misc'][6]],True)
  6541. item_name = helpc.items[0].name
  6542. test_loot = helpc.loot(0)
  6543. run = False
  6544. if test_loot == True:
  6545. sfx.play('pickup')
  6546. string = '+[' + item_name + ']'
  6547. message.add(string)
  6548. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]] = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace
  6549. else:
  6550. message.add('This workbench seems to be attached to the floor.')
  6551. run = False
  6552. elif ui == 'x':
  6553. run = False
  6554. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'alchemist':
  6555. #this is a alchemists's workshop
  6556. run = True
  6557. first_call = True
  6558. while run:
  6559. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6560. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6561. screen.render_request('['+key_name['e']+'] - brew a potion (-5 Herbs)', '['+key_name['b']+'] - take a potion', '['+key_name['x']+'] - leave',first_call)
  6562. else:
  6563. screen.render_request('['+key_name['e']+'] - XXXXXXXXXXXX ', '['+key_name['b']+'] - take a potion', '['+key_name['x']+'] - leave',first_call)
  6564. else:
  6565. screen.render_request('['+key_name['e']+'] - brew a potion (-5 Herbs)', '['+key_name['b']+'] - pick up workshop', '['+key_name['x']+'] - leave',first_call)
  6566. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,0,mouse=game_options.mousepad)
  6567. first_call = False
  6568. if ui == 'exit':
  6569. exitgame = True
  6570. screen.render_load(5)
  6571. save(world,player,time,gods,save_path,os.sep)
  6572. screen.save_tmp_png()
  6573. master_loop = False
  6574. playing = False
  6575. run = False
  6576. return('exit')
  6577. if ui == 'e':
  6578. test = False
  6579. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6580. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6581. test = True
  6582. else:
  6583. test = True
  6584. if test == True:
  6585. if player.inventory.materials.herb >= 5:
  6586. ordenary_potions = (il.ilist['food'][13],il.ilist['food'][14],il.ilist['food'][15],il.ilist['food'][16],il.ilist['food'][32])
  6587. #ordenary potions are: p.o. healing, p.o. feeding, p.o. refreshing, p.o. vitalising
  6588. strong_potions = (il.ilist['food'][17],il.ilist['food'][18],il.ilist['food'][19],il.ilist['food'][20],il.ilist['food'][33],il.ilist['food'][34])
  6589. #strong potions are: s.p.o. healing, s.p.o. feeding, s.p.o. refreshing, s.p.o. vitalising
  6590. upgrade_potions = (il.ilist['food'][21],il.ilist['food'][22],il.ilist['food'][23],il.ilist['food'][24],il.ilist['food'][35])
  6591. #upgrade potions are: p.o. hunger, p.o. thirst, p.o. tiredness, p.o. life
  6592. choose = random.randint(0,99)
  6593. if player.skill.alchemy == 'Novice':
  6594. if choose < 85: #make a ordenary potion(85%)
  6595. items = ordenary_potions
  6596. elif choose < 95:#make a strong potion(10%)
  6597. items = strong_potions
  6598. else:#make a upgrade potion(5%)
  6599. items = upgrade_potions
  6600. elif player.skill.alchemy == 'Adept':
  6601. if choose < 70: #make a ordenary potion(70%)
  6602. items = ordenary_potions
  6603. elif choose < 90:#make a strong potion(20%)
  6604. items = strong_potions
  6605. else:#make a upgrade potion(10%)
  6606. items = upgrade_potions
  6607. elif player.skill.alchemy == 'Master':
  6608. if choose < 50: #make a ordenary potion(50%)
  6609. items = ordenary_potions
  6610. elif choose < 80:#make a strong potion(30%)
  6611. items = strong_potions
  6612. else:#make a upgrade potion(20%)
  6613. items = upgrade_potions
  6614. choose = random.randint(0, len(items)-1)
  6615. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] == 0:
  6616. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] = container([items[choose]],False)
  6617. else:
  6618. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items.append(items[choose])
  6619. sfx.play('alchemy')
  6620. message_string = 'You brewed a ' + items[choose].name + '.'
  6621. message.add(message_string)
  6622. player.inventory.materials.herb -= 5
  6623. run = False
  6624. else:
  6625. message.add('You do have not enough herbs!')
  6626. run = False
  6627. elif ui == 'b':
  6628. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6629. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].inventory(False)
  6630. run = False
  6631. else:
  6632. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace.techID != tl.tlist['sanctuary'][0].techID:
  6633. #this ws dosen't stand inside the sanctuary
  6634. helpc = container([il.ilist['misc'][7]],True)
  6635. item_name = helpc.items[0].name
  6636. test_loot = helpc.loot(0)
  6637. run = False
  6638. if test_loot == True:
  6639. sfx.play('pickup')
  6640. string = '+[' + item_name + ']'
  6641. message.add(string)
  6642. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]] = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace
  6643. else:
  6644. message.add('This workshop seems to be attached to the floor.')
  6645. run = False
  6646. elif ui == 'x':
  6647. run = False
  6648. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'furnace':
  6649. #this is a furnace
  6650. run = True
  6651. first_call = True
  6652. while run:
  6653. screen.render_request('['+key_name['e']+'] - fire up the furnace (-10 wood)', ' ', '['+key_name['x']+'] - leave',first_call)
  6654. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,0,mouse=game_options.mousepad)
  6655. first_call = False
  6656. if ui == 'exit':
  6657. exitgame = True
  6658. screen.render_load(5)
  6659. save(world,player,time,gods,save_path,os.sep)
  6660. screen.save_tmp_png()
  6661. master_loop = False
  6662. playing = False
  6663. run = False
  6664. return('exit')
  6665. if ui == 'e':
  6666. if player.inventory.materials. wood >= 10:
  6667. sfx.play('flame')
  6668. message.add('You ligth up a fire.')
  6669. for i in range (0,len(player.inventory.food)):
  6670. if player.inventory.food[i] != player.inventory.nothing and player.inventory.food[i].rotten == False:
  6671. if player.inventory.food[i].techID == il.ilist['food'][4].techID: #this is a fish
  6672. message.add('You grill a fish.')
  6673. player.inventory.food[i] = deepcopy(il.ilist['food'][5])#turn a fish into a grilled fish
  6674. elif player.inventory.food[i].techID == il.ilist['food'][6].techID: #this are crops
  6675. message.add('You bake a bread.')
  6676. player.inventory.food[i] = deepcopy(il.ilist['food'][7])#turn crops into bread
  6677. elif player.inventory.food[i].techID == il.ilist['food'][7].techID: #this is a bread
  6678. message.add('You bake a bread for a second time.')
  6679. player.inventory.food[i] = deepcopy(il.ilist['food'][8])#turn a bread into rusk
  6680. elif player.inventory.food[i].techID == il.ilist['food'][9].techID: #this is raw meat
  6681. message.add('You grill raw meat.')
  6682. player.inventory.food[i] = deepcopy(il.ilist['food'][10])#turn raw meat into a grilled meat
  6683. elif player.inventory.food[i].techID == il.ilist['food'][11].techID: #this is a cult. mushroom
  6684. message.add('You grill a mushroom.')
  6685. player.inventory.food[i] = deepcopy(il.ilist['food'][12])#turn a cult. mushroom into a grilled mushroom
  6686. elif player.inventory.food[i].techID == il.ilist['food'][25].techID: #this is a jellyfish
  6687. message.add('You grill a jellyfish.')
  6688. player.inventory.food[i] = deepcopy(il.ilist['food'][26])#turn a jellyfish into a grilled jellyfish
  6689. elif player.inventory.food[i].techID == il.ilist['food'][0].techID: #this are red berries
  6690. message.add('You make some red jelly.')
  6691. player.inventory.food[i] = deepcopy(il.ilist['food'][29])#turn red berries into red jelly
  6692. elif player.inventory.food[i].techID == il.ilist['food'][27].techID: #this are blue berries
  6693. message.add('You make some blue jelly.')
  6694. player.inventory.food[i] = deepcopy(il.ilist['food'][30])#turn blue berries into blue jelly
  6695. elif player.inventory.food[i].techID == il.ilist['food'][28].techID: #this are red berries
  6696. message.add('You make some yellow jelly.')
  6697. player.inventory.food[i] = deepcopy(il.ilist['food'][31])#turn yellow berries into yellow jelly
  6698. elif player.inventory.food[i].techID == il.ilist['food'][38].techID: #this is corn
  6699. message.add('You make some popcorn.')
  6700. player.inventory.food[i] = deepcopy(il.ilist['food'][39])#turn corn into popcorn
  6701. elif player.inventory.food[i].techID == il.ilist['food'][40].techID: #this is an apple
  6702. message.add('You grill an apple.')
  6703. player.inventory.food[i] = deepcopy(il.ilist['food'][41])#turn apple into grilled apple
  6704. elif player.inventory.food[i].techID == il.ilist['food'][42].techID: #this is a golden apple
  6705. message.add('You grill a golden apple.')
  6706. player.inventory.food[i] = deepcopy(il.ilist['food'][43])#turn apple into grilled golden apple
  6707. ####add more here
  6708. run = False
  6709. else:
  6710. message.add('You do not have enough wood!')
  6711. run = False
  6712. elif ui == 'x':
  6713. run = False
  6714. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'altar':
  6715. #this is a altar
  6716. run = True
  6717. first_call = True
  6718. while run:
  6719. if player.difficulty == 0 or player.difficulty == 4: #playing on easy or sandbox
  6720. if gods.judgement() == True:
  6721. pray_string = '['+key_name['e']+'] - pray (save)'
  6722. else:
  6723. pray_string = '['+key_name['e']+'] - pray (not save)'
  6724. else:
  6725. pray_string = '['+key_name['e']+'] - pray'
  6726. screen.render_request(pray_string, '['+key_name['b']+'] - identify ', '['+key_name['x']+'] - leave',first_call)
  6727. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,0,mouse=game_options.mousepad)
  6728. first_call = False
  6729. if ui == 'exit':
  6730. exitgame = True
  6731. screen.render_load(5)
  6732. save(world,player,time,gods,save_path,os.sep)
  6733. screen.save_tmp_png()
  6734. master_loop = False
  6735. playing = False
  6736. run = False
  6737. return('exit')
  6738. if ui == 'e':
  6739. judgement = gods.judgement() # see if the player is supported by the gods
  6740. if judgement == True:
  6741. cursed_items = 0
  6742. bodyparts = ('Hold(R)', 'Hold(L)', 'Head', 'Body', 'Legs', 'Feet', 'Hand', 'Neck', 'Axe', 'Pickaxe')
  6743. for i in bodyparts:#check if player wears some cursed equipment
  6744. if player.inventory.wearing[i].cursed < 1 and i != player.inventory.nothing:
  6745. cursed_items += 1
  6746. if (player.lp*100)/player.attribute.max_lp < 20:#player has less then 20% of lp -> heal
  6747. player.lp = player.attribute.max_lp
  6748. message.add('The gods heal your wounds.')
  6749. gods.mood -= 10
  6750. run = False
  6751. elif (player.attribute.hunger*100)/player.attribute.hunger_max < 20 or (player.attribute.thirst*100)/player.attribute.thirst_max < 20 or (player.attribute.tiredness*100)/player.attribute.tiredness_max < 20:
  6752. #player is very hungry,thirsty or tired -> refresh
  6753. player.attribute.hunger = player.attribute.hunger_max
  6754. player.attribute.thirst = player.attribute.thirst_max
  6755. player.attribute.tiredness = player.attribute.tiredness_max
  6756. message.add('The gods rerfresh you.')
  6757. gods.mood -= 10
  6758. run = False
  6759. elif cursed_items > 0:#player has some cursed items
  6760. bodyparts = ('Hold(R)', 'Hold(L)', 'Head', 'Body', 'Legs', 'Feet', 'Hand', 'Neck', 'Axe', 'Pickaxe')
  6761. for j in bodyparts:
  6762. if player.inventory.wearing[j].cursed < 1 and player.inventory.wearing[j] != player.inventory.nothing:
  6763. item = item_wear(player.inventory.wearing[j].classe, player.inventory.wearing[j].material, player.inventory.wearing[j].plus, player.inventory.wearing[j].state, 1, player.inventory.wearing[j].known)
  6764. player.inventory.wearing[j] = item
  6765. message.add('The gods remove curses from your equipment.')
  6766. gods.mood -= 10
  6767. run = False
  6768. else:
  6769. message.add('The gods are pleased about you.')
  6770. run = False
  6771. else:
  6772. uncursed_items = 0
  6773. bodyparts = ('Hold(R)', 'Hold(L)', 'Head', 'Body', 'Legs', 'Feet', 'Hand', 'Neck','Axe','Pickaxe')
  6774. for i in bodyparts:#check if player wears some cursed equipment
  6775. if player.inventory.wearing[i].cursed > 0 and player.inventory.wearing[i] != player.inventory.nothing:
  6776. uncursed_items += 1
  6777. if uncursed_items > 0:
  6778. for j in bodyparts:
  6779. if player.inventory.wearing[j].cursed > 0 and player.inventory.wearing[j] != player.inventory.nothing:
  6780. item = item_wear(player.inventory.wearing[j].classe,player.inventory.wearing[j].material,player.inventory.wearing[j].plus, player.inventory.wearing[j].state, 0, player.inventory.wearing[j].known)
  6781. player.inventory.wearing[j] = item
  6782. message.add('The gods are angry and curse your equipment.')
  6783. run = False
  6784. else:
  6785. player.lp -= 5
  6786. message.add('The gods are angry and hurt you')
  6787. run = False
  6788. elif ui == 'b':
  6789. if gods.judgement() == True:
  6790. num_ident = 0
  6791. bodyparts = ('Hold(R)', 'Hold(L)', 'Head', 'Body', 'Legs', 'Feet', 'Hand', 'Neck', 'Axe', 'Pickaxe')
  6792. for i in bodyparts:
  6793. if player.inventory.wearing[i] != player.inventory.nothing and player.inventory.wearing[i].known == False:
  6794. player.inventory.wearing[i].identification()
  6795. num_ident += 1
  6796. for j in range (0, len(player.inventory.equipment)):
  6797. if player.inventory.equipment[j] != player.inventory.nothing and player.inventory.equipment[j].known == False:
  6798. player.inventory.equipment[j].identification()
  6799. num_ident += 1
  6800. if num_ident > 0:
  6801. message.add('Now you are aware of your equipments attributes.')
  6802. gods.mood -= num_ident
  6803. else:
  6804. message.add('You have nothing that could be identified.')
  6805. run = False
  6806. else:
  6807. message.add('The gods deny to identify your equipment!')
  6808. run = False
  6809. elif ui == 'x':
  6810. run = False
  6811. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'activate_portal':
  6812. head_string = 'Portal (requires: LVL '+str(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].special_num)+' & '+ str(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_resources[1])+' gems)'
  6813. if player.lvl >= world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].special_num and player.inventory.materials.gem >= world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_resources[1]:
  6814. a_string = '['+key_name['e']+'] - activate'
  6815. activate = True
  6816. else:
  6817. a_string = ' '
  6818. activate = False
  6819. l_string = '['+key_name['x']+'] - leave'
  6820. run = True
  6821. while run:
  6822. screen.render_request(head_string,a_string,l_string)
  6823. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  6824. if ui == 'exit':
  6825. exitgame = True
  6826. screen.render_load(5)
  6827. save(world,player,time,gods,save_path,os.sep)
  6828. screen.save_tmp_png()
  6829. master_loop = False
  6830. playing = False
  6831. run = False
  6832. return('exit')
  6833. if ui == 'e' and activate == True:
  6834. player.inventory.materials.gem -= world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_resources[1]
  6835. if player.inventory.materials.gem < 0:#only to be sure
  6836. player.inventory.materials.gem = 0#
  6837. replace = deepcopy(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace)
  6838. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]] = deepcopy(tl.tlist[world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_tiles[0]][world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_tiles[1]])
  6839. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace = replace
  6840. sfx.play('portal')
  6841. run = False
  6842. if ui == 'x':
  6843. run = False
  6844. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'go_fortress':
  6845. screen.render_fade(True,False)
  6846. try:
  6847. pos = world.maplist[0]['fortress_0_0'].find_first(tl.tlist['portal'][2])
  6848. except:
  6849. test = False
  6850. while test == False:
  6851. test = world.elfish_generator(0)
  6852. pos = world.maplist[0]['fortress_0_0'].find_first(tl.tlist['portal'][2])
  6853. player.pos[0] = pos[0]
  6854. player.pos[1] = pos[1]
  6855. player.pos[2] = 0#only to be sure
  6856. player.on_map = 'fortress_0_0'
  6857. player.stand_check()
  6858. sfx.play('portal')
  6859. screen.render_fade(False,True)
  6860. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'return_fortress':
  6861. pos = world.maplist[self.pos[2]]['local_0_0'].find_first(tl.tlist['portal'][1])
  6862. screen.render_fade(True,False)
  6863. player.pos[0] = pos[0]
  6864. player.pos[1] = pos[1]
  6865. player.pos[2] = 0#only to be sure
  6866. player.on_map = 'local_0_0'
  6867. player.stand_check()
  6868. sfx.play('portal')
  6869. screen.render_fade(False,True)
  6870. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'go_desert':
  6871. screen.render_fade(True,False)
  6872. try:
  6873. pos = world.maplist[self.pos[2]]['desert_0_0'].find_first(tl.tlist['portal'][5])
  6874. except:
  6875. world.desert_generator(20)
  6876. world.cave_generator(5,'desert')
  6877. world.border_generator(6,'desert')
  6878. pos = world.maplist[self.pos[2]]['desert_0_0'].find_first(tl.tlist['portal'][5])
  6879. player.pos[0] = pos[0]
  6880. player.pos[1] = pos[1]
  6881. player.pos[2] = 0#only to be sure
  6882. player.on_map = 'desert_0_0'
  6883. player.stand_check()
  6884. screen.render_fade(False,True)
  6885. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'return_desert':
  6886. pos = world.maplist[self.pos[2]]['local_0_0'].find_first(tl.tlist['portal'][4])
  6887. screen.render_fade(True,False)
  6888. player.pos[0] = pos[0]
  6889. player.pos[1] = pos[1]
  6890. player.pos[2] = 0#only to be sure
  6891. player.on_map = 'local_0_0'
  6892. player.stand_check()
  6893. screen.render_fade(False,True)
  6894. elif world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:#interaction with a container eg.: a chest
  6895. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].inventory()
  6896. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'shop' or world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].techID == tl.tlist['shop'][0].techID:#this is shop floor
  6897. if world.maplist[self.pos[2]][self.on_map].map_type == 'grot':
  6898. list_items = ('Scroll of Return(1 Gem)','Enchanted Enhancement Powder(5 Gem)','Copper Pickaxe(3 Gem)','Copper Axe(3 Gem)', 'Grilled Fish(1 Gem)', 'Torch(1 Gem)')
  6899. prices = (1,5,3,3,1,1)
  6900. axe = item_wear('axe',11,0)
  6901. pickaxe = item_wear('pickaxe',11,0)
  6902. items = (il.ilist['misc'][33],il.ilist['misc'][42],pickaxe,axe,il.ilist['food'][5],il.ilist['misc'][44])
  6903. elif world.maplist[self.pos[2]][self.on_map].map_type == 'elfish_fortress':
  6904. list_items = ('Scroll of Return(1 Gem)','Mysterious Blue Crystal(10 Gem)','Steel Pickaxe(5 Gem)','Steel Axe(5 Gem)', 'Red Berries(1 Gem)', 'Torch(1 Gem)')
  6905. prices = (1,10,5,5,1,1)
  6906. axe = item_wear('axe',15,0)
  6907. pickaxe = item_wear('pickaxe',15,0)
  6908. items = (il.ilist['misc'][33],il.ilist['misc'][41],pickaxe,axe,il.ilist['food'][0],il.ilist['misc'][44])
  6909. elif world.maplist[self.pos[2]][self.on_map].map_type == 'orcish_mines':
  6910. list_items = ('Scroll of Return(1 Gem)','Bomb(1 Gem)','Titan Pickaxe(7 Gem)','Titan Axe(7 Gem)', 'Grilled Meat(1 Gem)', 'Torch(1 Gem)')
  6911. prices = (1,1,7,7,1,1)
  6912. axe = item_wear('axe',18,0)
  6913. pickaxe = item_wear('pickaxe',18,0)
  6914. items = (il.ilist['misc'][33],il.ilist['misc'][24],pickaxe,axe,il.ilist['food'][10],il.ilist['misc'][44])
  6915. elif world.maplist[self.pos[2]][self.on_map].map_type == 'pharmacy':
  6916. list_items = ('Bandage(1 Gem)','Eyedrops(1 Gem)','Antidote(1 Gem)','Holy Water(3 Gem)', 'Potion of Healing(1 Gem)', 'Strong Potion of Healing(5 Gem)')
  6917. prices = (1,1,1,3,1,5)
  6918. items = (il.ilist['misc'][74],il.ilist['misc'][75],il.ilist['misc'][76],il.ilist['misc'][77],il.ilist['food'][13],il.ilist['food'][17])
  6919. elif world.maplist[self.pos[2]][self.on_map].map_type == 'pickaxe':
  6920. list_items = ('Wooden Pickaxe(1 Gem)','Tin Pickaxe(2 Gem)','Bronze Pickaxe(3 Gem)','Steel Pickaxe(4 Gem)', 'Titan Pickaxe(5 Gem)', 'Magnicum Pickaxe(6 Gem)')
  6921. prices = (1,2,3,4,5,6)
  6922. pickaxe1 = item_wear('pickaxe',0,0)
  6923. pickaxe2 = item_wear('pickaxe',6,0)
  6924. pickaxe3 = item_wear('pickaxe',11,0)
  6925. pickaxe4 = item_wear('pickaxe',15,0)
  6926. pickaxe5 = item_wear('pickaxe',18,0)
  6927. pickaxe6 = item_wear('pickaxe',20,0)
  6928. items = (pickaxe1,pickaxe2,pickaxe3,pickaxe4,pickaxe5,pickaxe6)
  6929. elif world.maplist[self.pos[2]][self.on_map].map_type == 'hardware':
  6930. list_items = ('Steel Helmet(4 Gem)','Steel Armor(4 Gem)','Steel Cuisse(4 Gem)','Steel Shoes(4 Gem)', 'Steel Sword(4 Gem)', 'Steel Rune Staff(4 Gem)')
  6931. prices = (4,4,4,4,4,4)
  6932. item1 = item_wear('helmet',15,0)
  6933. item2 = item_wear('armor',15,0)
  6934. item3 = item_wear('cuisse',15,0)
  6935. item4 = item_wear('shoes',15,0)
  6936. item5 = item_wear('sword',15,0)
  6937. item6 = item_wear('rune staff',15,0)
  6938. items = (item1,item2,item3,item4,item5,item6)
  6939. elif world.maplist[self.pos[2]][self.on_map].map_type == 'deco':
  6940. list_items = ('Bonsai(1 Gem)','Houseplant(1 Gem)','Pendolum Clock(1 Gem)','Hourglass(1 Gem)', 'Neko Statue(1 Gem)', 'Orc Statue(1 Gem)')
  6941. prices = (1,1,1,1,1,1)
  6942. items = (il.ilist['misc'][66],il.ilist['misc'][67],il.ilist['misc'][60],il.ilist['misc'][63],il.ilist['misc'][59],il.ilist['misc'][56])
  6943. elif world.maplist[self.pos[2]][self.on_map].map_type == 'book':
  6944. list_items = ('Spellbook of Light(2 Gem)','Spellbook of Flames(5 Gem)','Scroll of Identify(1 Gem)','Scroll of Repair(2 Gem)', 'Spellbook of Teleport(2 Gem)', 'Spellbook of Healing(5 Gem)')
  6945. prices = (2,5,1,2,2,5)
  6946. items = (il.ilist['misc'][46],il.ilist['misc'][36],il.ilist['misc'][25],il.ilist['misc'][27],il.ilist['misc'][32],il.ilist['misc'][30])
  6947. elif world.maplist[self.pos[2]][self.on_map].map_type == 'bomb':
  6948. list_items = ('boMb(1 Gem)','eXplozive(1 Gem)','BriMstone(1 Gem)','HeAtet stOne(1 Gem)', 'darT(1 Gem)', 'Tork(1 Gem)')
  6949. prices = (1,1,1,1,1,1)
  6950. items = (il.ilist['misc'][24],il.ilist['misc'][72],il.ilist['misc'][73],il.ilist['misc'][71],il.ilist['misc'][79],il.ilist['misc'][44])
  6951. else:#only for fallback and general store
  6952. list_items = ('Scroll of Return(1 Gem)','Magic Map(5 Gem)','Wooden Pickaxe(1 Gem)','Wooden Axe(1 Gem)', 'Grilled Fish(1 Gem)', 'Torch(1 Gem)')
  6953. prices = (1,5,1,1,1,1)
  6954. axe = item_wear('axe',0,0)
  6955. pickaxe = item_wear('pickaxe',0,0)
  6956. items = (il.ilist['misc'][33],il.ilist['misc'][81],pickaxe,axe,il.ilist['food'][5],il.ilist['misc'][44])
  6957. headline = 'You have ' + str(player.inventory.materials.gem) + ' gems. What do you want to buy?'
  6958. choice = screen.get_choice(headline,list_items,True)
  6959. if choice != 'Break':
  6960. if prices[choice] <= player.inventory.materials.gem:
  6961. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] = container([items[choice]])
  6962. test = world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].loot(0)
  6963. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] = 0#del the container to be sure
  6964. if test == True:
  6965. player.inventory.materials.gem -= prices[choice]
  6966. message.add('The shopkeeper thanks you for your purchacing.')
  6967. sfx.play('shop')
  6968. else:
  6969. message.add('Your bags are to full to buy this item.')
  6970. else:
  6971. message.add('You havn\'t got enough gems to buy this item.')
  6972. else:
  6973. message.add('Never Mind.')
  6974. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'grassland_down':#this is a grassland dungeon stair down
  6975. screen.render_fade(True,False)
  6976. plus = world.maplist[self.pos[2]][self.on_map].monster_plus
  6977. if plus < 5:
  6978. world.dungeon_generator(plus+1,True)
  6979. else:
  6980. world.dungeon_generator(plus+1,False)
  6981. if player.on_map != 'dungeon_0_0':
  6982. player.last_z = player.pos[2]
  6983. player.on_map = 'dungeon_0_0'
  6984. player.pos[2] = 1
  6985. pos = world.maplist[player.pos[2]][player.on_map].find_first(tl.tlist['dungeon'][8])
  6986. player.pos[0] = pos[0]
  6987. player.pos[1] = pos[1]
  6988. player.stand_check()
  6989. screen.render_fade(False,True)
  6990. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'grassland_up':#this is a grassland dungeon stair up
  6991. choose = screen.get_choice('Do you want to leave?',['No','Yes'],True)
  6992. if choose == 1:
  6993. screen.render_fade(True,False)
  6994. player.on_map = player.last_map
  6995. player.pos[2] = player.last_z
  6996. pos = world.maplist[player.pos[2]][player.on_map].find_first(tl.tlist['dungeon'][7])
  6997. player.pos[0] = pos[0]
  6998. player.pos[1] = pos[1]
  6999. player.stand_check()
  7000. screen.render_fade(False,True)
  7001. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'tomb_down':#this is a grassland dungeon stair down
  7002. screen.render_fade(True,False)
  7003. plus = world.maplist[self.pos[2]][self.on_map].monster_plus
  7004. if plus < 12:
  7005. world.dungeon_generator(plus+1,stair_down=True,style='Tomb')
  7006. else:
  7007. world.dungeon_generator(plus+1,stair_down=False,style='Tomb')
  7008. if player.on_map != 'dungeon_0_0':
  7009. player.last_z = player.pos[2]
  7010. player.on_map = 'dungeon_0_0'
  7011. player.pos[2] = 1
  7012. pos = world.maplist[player.pos[2]][player.on_map].find_first(tl.tlist['dungeon'][19])
  7013. player.pos[0] = pos[0]
  7014. player.pos[1] = pos[1]
  7015. player.stand_check()
  7016. screen.render_fade(False,True)
  7017. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_grou