main.py 476 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618
  1. #! /usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. #This file is part of RogueBox Adventures.
  4. #
  5. # RogueBox Adventures is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # RogueBox Adventures is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with RogueBox Adventures. If not, see <http://www.gnu.org/licenses/>.
  17. import datetime
  18. import time
  19. from time import sleep as sleep
  20. import sys
  21. import os
  22. low_res = False
  23. gcwz_input = False
  24. home_save = False
  25. cheat_mode = False
  26. Time_ready = False
  27. entrance_x = 0
  28. entrance_y = 0
  29. basic_path = os.path.dirname(os.path.realpath('main.py')) #just get the execution path for resources
  30. for t in sys.argv:
  31. if t == '-m':
  32. p = os.path.expanduser(basic_path)
  33. lf = open('rba.desktop','w')
  34. lf.write('[Desktop Entry]\n')
  35. lf.write('Type=Application\n')
  36. lf.write('Name=RogueBox Adventures\n')
  37. lf.write('Comment=A RogueBox Game\n')
  38. lf.write('Exec=sh ' + p + os.sep + 'LIB' + os.sep + 'run.sh\n')
  39. lf.write('Icon=' + p + os.sep + 'icon_big.png\n')
  40. lf.write('Terminal=false\n')
  41. lf.write('Categories=Game;')
  42. lf.close()
  43. rf_path = p + os.sep + 'LIB' + os.sep + 'run.sh'
  44. rf = open(rf_path,'w')
  45. rf.write('#This file was generated automatically. Please don\'t change anything.\n')
  46. rf.write('cd ' + p + '\n')
  47. rf.write('python ' + p + os.sep + 'run.py')
  48. sys_com = 'chmod +x ' + p + os.sep + 'rba.desktop'
  49. os.system(sys_com)
  50. exit(0)
  51. if t == '-c':
  52. cheat_mode = True
  53. if t == '-g':
  54. gcwz_input = True
  55. if t == '-h':
  56. home_save = True
  57. lib_path = basic_path + os.sep + 'LIB'
  58. data_path = basic_path + os.sep + 'DATA'
  59. if home_save == False:
  60. save_path = basic_path + os.sep + 'SAVE' + os.sep + 'World0'
  61. else:
  62. save_path = os.path.expanduser('~') + os.sep + '.config' + os.sep + 'RogueBox-Adventures' + os.sep + 'SAVE' + os.sep + 'World0'
  63. path = save_path.replace(os.sep+'World0','')
  64. if os.path.exists(path) == False:
  65. for c in range(0,5):
  66. ph = path + os.sep + 'World' + str(c)
  67. os.makedirs(ph)
  68. del path
  69. playing = False
  70. sys.path.append(lib_path)
  71. max_map_size = 52
  72. monitor = [0,0]
  73. try:
  74. import cPickle as p
  75. except:
  76. import pickle as p
  77. try:
  78. p.DEFAULT_PROTOCOL=0
  79. except:
  80. p.HIGHEST_PROTOCOL=0
  81. import random
  82. if gcwz_input == True:
  83. from getch_gcwz import *
  84. else:
  85. from getch import *
  86. from tile import tile
  87. from attribute import attribute
  88. from item import *
  89. from countdown import *
  90. import pygame
  91. from gra_files import *
  92. from util import *
  93. from monster import monster
  94. from copy import deepcopy
  95. from buffs import buffs
  96. from itemlist import *
  97. from tilelist import *
  98. from monsterlist import *
  99. from text import texts
  100. from skill import *
  101. from dialog import *
  102. from version import *
  103. game_options = game_options(basic_path,home_save)
  104. if game_options.check_version == 1:
  105. ver_string = check_version()
  106. else:
  107. ver_string = ' '
  108. class g_screen():
  109. def __init__(self, mode = game_options.screenmode, show_logo = True):
  110. string = 'RogueBoxAdventures ' + version +' "'+version_name+'"'
  111. pygame.display.set_caption(string)
  112. icon = pygame.image.load('icon_small.png')
  113. pygame.display.set_icon(icon)
  114. global monitor
  115. self.fire_mode = 0 #0: normal, 1: fire
  116. self.win_mode = mode
  117. self.hit_matrix = []
  118. for y in range(0,12):
  119. self.hit_matrix.append([])
  120. for x in range(0,15):
  121. self.hit_matrix[y].append(0)
  122. pygame.init()
  123. display_info = pygame.display.Info()
  124. if monitor == [0,0]:
  125. monitor[0] = display_info.current_w
  126. monitor[1] = display_info.current_h
  127. self.displayx = monitor[0]
  128. self.displayy = monitor[1]
  129. #check if the screenmode is 16:9
  130. self.displayx = monitor[0]-monitor[0]%640
  131. self.displayy = monitor[1]-monitor[1]%360
  132. winstyle = pygame.FULLSCREEN
  133. if cheat_mode == True and self.win_mode == 2:
  134. self.win_mode = 1 #disable fullscreen in cheat mode
  135. if self.win_mode == 2:
  136. self.screen = pygame.display.set_mode((self.displayx,self.displayy),winstyle)
  137. pygame.mouse.set_visible(game_options.mousepad)
  138. elif self.win_mode == 0 and low_res == False:
  139. self.screen = pygame.display.set_mode((640,360))
  140. self.displayx = 640
  141. self.displayy = 360
  142. elif self.win_mode == 1 and low_res == False:
  143. self.screen = pygame.display.set_mode((1280,720))
  144. self.displayx = 1280
  145. self.displayy = 720
  146. font_path = basic_path + os.sep + 'FONT' + os.sep + 'PressStart2P.ttf'
  147. self.font = pygame.font.Font(font_path,8)
  148. if low_res == True:
  149. str_ext = '_low_res'
  150. else:
  151. str_ext = ''
  152. if __name__ == '__main__':
  153. show_logo = False
  154. if show_logo == True:
  155. display_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep
  156. ran = random.randint(0,4)
  157. i_name = display_path + 'logo' + str(ran) + str_ext + '.png'
  158. i = pygame.image.load(i_name)
  159. i = pygame.transform.scale(i,(self.displayx,self.displayy))
  160. self.screen.blit(i,(0,0))
  161. pygame.display.flip()
  162. getch(640,360,mode=1)
  163. display_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep
  164. ran = random.randint(0,4)
  165. i_name = display_path + 'logo_gpl' + str_ext + '.png'
  166. i = pygame.image.load(i_name)
  167. i = pygame.transform.scale(i,(self.displayx,self.displayy))
  168. self.screen.blit(i,(0,0))
  169. pygame.display.flip()
  170. getch(640,360,mode=1)
  171. display_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep
  172. i_name = display_path + 'oga' + str_ext + '.png'
  173. i = pygame.image.load(i_name)
  174. i = pygame.transform.scale(i,(self.displayx,self.displayy))
  175. self.screen.blit(i,(0,0))
  176. pygame.display.flip()
  177. getch(640,360,mode=1)
  178. def render_fade(self,fadeout,fadein,menu='default'):
  179. if menu == 'inventory':
  180. bg = player.inventory.render(0,0,simulate=True)
  181. elif menu == 'screen':
  182. bg = screen.screen
  183. elif menu == 'loot':
  184. bg = world.maplist[player.pos[2]][player.on_map].containers[player.pos[1]][player.pos[0]].inventory(simulated=True)
  185. elif menu == 'brake':
  186. bg = screen.render_brake(simulate=True)
  187. elif menu == 'main':
  188. bg = screen.render_main_menu(simulate=True)
  189. else:
  190. bg = self.render(0,True)
  191. clock = pygame.time.Clock()
  192. if fadein:
  193. for i in range(255,0,-15):
  194. helpsur = pygame.Surface((self.displayx,self.displayy))
  195. helpsur.fill((48,48,48))
  196. helpsur.set_alpha(i)
  197. self.screen.blit(bg,(0,0))
  198. self.screen.blit(helpsur,(0,0))
  199. pygame.display.flip()
  200. clock.tick(510)
  201. if fadeout:
  202. for i in range(0,255,15):
  203. helpsur = pygame.Surface((self.displayx,self.displayy))
  204. helpsur.fill((48,48,48))
  205. helpsur.set_alpha(i)
  206. self.screen.blit(bg,(0,0))
  207. self.screen.blit(helpsur,(0,0))
  208. pygame.display.flip()
  209. clock.tick(510)
  210. def reset_hit_matrix(self):
  211. self.hit_matrix = []
  212. for y in range(0,12):
  213. self.hit_matrix.append([])
  214. for x in range(0,15):
  215. self.hit_matrix[y].append(0)
  216. def write_hit_matrix(self,x,y,style):
  217. #style: 0:nothing
  218. # 1:fire_path
  219. # 2:fire_path_monster
  220. # 3:miss
  221. # 4:hit
  222. # 5:critical
  223. # 6:heal
  224. # 7:teleport
  225. # 8:minus_gem
  226. # 9:plus_gem
  227. # 10:plus_fish
  228. # 11:plus_shoe
  229. # 12:monster_lvl_up
  230. # 13:monster_die
  231. # 14:attention
  232. # 15:found
  233. # 16:drop
  234. # 17:fear
  235. # 18:blood_minus
  236. # 19:blood_plus
  237. # 20:throw
  238. # 21:minus_item
  239. # 22:plus_item
  240. # 23:spellwave
  241. xx = x - player.pos[0] + 8
  242. yy = y - player.pos[1] + 6
  243. try:
  244. if xx >= 0 and yy >= 0:
  245. self.hit_matrix[yy][xx] = style
  246. except:
  247. None
  248. def render_hits(self):
  249. s = pygame.Surface((480,360))
  250. s.fill((255,0,255))
  251. start = 0
  252. for y in range(start,len(self.hit_matrix)):
  253. for x in range(start,len(self.hit_matrix[0])):
  254. if self.hit_matrix[y][x] == 1:
  255. s.blit(gra_files.gdic['display'][11],(((x-start)*32),(y-start)*32))
  256. elif self.hit_matrix[y][x] == 2:
  257. s.blit(gra_files.gdic['display'][12],(((x-start)*32),(y-start)*32))
  258. elif self.hit_matrix[y][x] == 3:
  259. s.blit(gra_files.gdic['display'][13],(((x-start)*32),(y-start)*32))
  260. elif self.hit_matrix[y][x] == 4:
  261. s.blit(gra_files.gdic['display'][14],(((x-start)*32),(y-start)*32))
  262. elif self.hit_matrix[y][x] == 5:
  263. s.blit(gra_files.gdic['display'][15],(((x-start)*32),(y-start)*32))
  264. elif self.hit_matrix[y][x] == 6:
  265. s.blit(gra_files.gdic['display'][23],(((x-start)*32),(y-start)*32))
  266. elif self.hit_matrix[y][x] == 7:
  267. s.blit(gra_files.gdic['display'][24],(((x-start)*32),(y-start)*32))
  268. elif self.hit_matrix[y][x] == 8:
  269. s.blit(gra_files.gdic['display'][26],(((x-start)*32),(y-start)*32))
  270. elif self.hit_matrix[y][x] == 9:
  271. s.blit(gra_files.gdic['display'][27],(((x-start)*32),(y-start)*32))
  272. elif self.hit_matrix[y][x] == 10:
  273. s.blit(gra_files.gdic['display'][42],(((x-start)*32),(y-start)*32))
  274. elif self.hit_matrix[y][x] == 11:
  275. s.blit(gra_files.gdic['display'][43],(((x-start)*32),(y-start)*32))
  276. elif self.hit_matrix[y][x] == 12:
  277. s.blit(gra_files.gdic['display'][51],(((x-start)*32),(y-start)*32))
  278. elif self.hit_matrix[y][x] == 13:
  279. s.blit(gra_files.gdic['display'][58],(((x-start)*32),(y-start)*32))
  280. elif self.hit_matrix[y][x] == 14:
  281. s.blit(gra_files.gdic['display'][59],(((x-start)*32),(y-start)*32))
  282. elif self.hit_matrix[y][x] == 15:
  283. s.blit(gra_files.gdic['display'][60],(((x-start)*32),(y-start)*32))
  284. elif self.hit_matrix[y][x] == 16:
  285. s.blit(gra_files.gdic['display'][61],(((x-start)*32),(y-start)*32))
  286. elif self.hit_matrix[y][x] == 17:
  287. s.blit(gra_files.gdic['display'][62],(((x-start)*32),(y-start)*32))
  288. elif self.hit_matrix[y][x] == 18:
  289. s.blit(gra_files.gdic['display'][63],(((x-start)*32),(y-start)*32))
  290. elif self.hit_matrix[y][x] == 19:
  291. s.blit(gra_files.gdic['display'][64],(((x-start)*32),(y-start)*32))
  292. elif self.hit_matrix[y][x] == 20:
  293. s.blit(gra_files.gdic['display'][65],(((x-start)*32),(y-start)*32))
  294. elif self.hit_matrix[y][x] == 21:
  295. s.blit(gra_files.gdic['display'][66],(((x-start)*32),(y-start)*32))
  296. elif self.hit_matrix[y][x] == 22:
  297. s.blit(gra_files.gdic['display'][67],(((x-start)*32),(y-start)*32))
  298. elif self.hit_matrix[y][x] == 23:
  299. s.blit(gra_files.gdic['display'][70],(((x-start)*32),(y-start)*32))
  300. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  301. s = s.convert_alpha()
  302. return s
  303. def render_main_menu(self,simulate=False):
  304. if simulate == False:
  305. screen.render_fade(False,True,'main')
  306. if home_save == False:
  307. display_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep
  308. alt_path = display_path
  309. else:
  310. display_path = os.path.expanduser('~') + os.sep + '.config' + os.sep + 'RogueBox-Adventures' + os.sep
  311. alt_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep
  312. num = 0
  313. master_loop = True
  314. run = True
  315. while run:
  316. s = pygame.Surface((640,360))
  317. s.fill((48,48,48))
  318. try:
  319. i_name = display_path + 'tmp.png'
  320. i = pygame.image.load(i_name)
  321. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  322. i = i.convert_alpha()
  323. s.blit(i,(0,0))
  324. except:
  325. i_name = alt_path + 'alt.png'
  326. i = pygame.image.load(i_name)
  327. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  328. i = i.convert_alpha()
  329. s.blit(i,(0,0))
  330. s.blit(gra_files.gdic['display'][16],(0,0))
  331. menu_list = ('PLAY','OPTIONS','CREDITS','QUIT')
  332. for c in range(0,len(menu_list)):
  333. name_image = self.font.render(menu_list[c],1,(0,0,0))
  334. s.blit(name_image,(210,145+(c*45)))
  335. s.blit(gra_files.gdic['display'][4],(185,138+(num*45)))
  336. version_info = 'v'+version+' "'+version_name+'"'
  337. ver_info_image1 = self.font.render(version_info,1,(0,0,0))
  338. ver_info_image2 = self.font.render(version_info,1,(255,255,255))
  339. s.blit(ver_info_image1,(107,85))
  340. s.blit(ver_info_image2,(105,85))
  341. if game_options.check_version == 1:
  342. if ver_string == 'This version is up to date.':
  343. ver_image = self.font.render(ver_string,1,(0,255,0))
  344. elif ver_string == 'Old version!!! Please update.':
  345. ver_image = self.font.render(ver_string,1,(255,0,0))
  346. else:
  347. ver_image = self.font.render(ver_string,1,(255,255,255))
  348. ver_image2 = self.font.render(ver_string,1,(0,0,0))
  349. s.blit(ver_image2,(12,340))
  350. s.blit(ver_image,(10,340))
  351. if game_options.mousepad == 0:
  352. s_h = pygame.Surface((160,360))
  353. s_h.fill((48,48,48))
  354. s.blit(s_h,(480,0))
  355. s_help = pygame.Surface((640,360))
  356. s_help.fill((48,48,48))
  357. s_help.blit(s,(80,0))
  358. s = s_help
  359. else:
  360. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  361. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  362. if simulate == True:
  363. return s
  364. self.screen.blit(s,(0,0))
  365. pygame.display.flip()
  366. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  367. if ui == 'exit':
  368. master_loop = False
  369. run = False
  370. if ui == 'w':
  371. num -= 1
  372. if num < 0:
  373. num = 0
  374. elif ui == 's':
  375. num += 1
  376. if num > 3:
  377. num = 3
  378. elif ui == 'e':
  379. if num == 0:
  380. test = screen.choose_save_path()
  381. if test == 'exit':
  382. master_loop = False
  383. run = False
  384. elif num == 1:
  385. test = screen.render_options()
  386. if test == 'exit':
  387. master_loop = False
  388. run = False
  389. elif num == 2:
  390. test = screen.render_credits()
  391. if test == 'exit':
  392. master_loop = False
  393. run = False
  394. elif num == 3:
  395. master_loop = False
  396. run = False
  397. return master_loop
  398. def render_crash(self):
  399. run = True
  400. while run:
  401. self.screen.fill((48,48,48))
  402. string = []
  403. string.append('Sorry, something went wrong.')
  404. string.append('Check out debug.txt for more informations.')
  405. debug_location = '('+save_path+')'
  406. for c in range(0,6):
  407. debug_location = debug_location.replace('World'+str(c),'debug.txt')
  408. string.append(debug_location)
  409. st = []
  410. for i in string:
  411. st.append(self.font.render(i,1,(255,255,255)))
  412. for j in range(0,len(st)):
  413. self.screen.blit(st[j],(5,25+j*25))
  414. pygame.display.flip()
  415. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  416. if ui != 'none':
  417. run = False
  418. def choose_save_path(self):
  419. global save_path
  420. global playing
  421. global master_loop
  422. global gra_files
  423. gra_files = g_files()
  424. if home_save == True:
  425. path = os.path.expanduser('~') + os.sep + '.config' + os.sep + 'RogueBox-Adventures'
  426. else:
  427. path = basic_path
  428. run = True
  429. while run:
  430. menu_items = []
  431. for c in range(0,5):
  432. save_path = path + os.sep + 'SAVE' + os.sep + 'World' + str(c)
  433. p_attribute = attribute(2,2,2,2,2,10,10)
  434. p_inventory = inventory()
  435. player_help = player_class ('-EMPTY SLOT-', 'local_0_0', p_attribute,p_inventory, build= 'Auto')
  436. if player_help.name != '-EMPTY SLOT-':
  437. item_string = player_help.name + ' LVL:' + str(player_help.lvl)
  438. else:
  439. item_string = '-EMPTY SLOT-'
  440. menu_items.append(item_string)
  441. menu_items.append('~~ERASE~~')
  442. menu_items.append('~~BACK~~')
  443. choice = screen.get_choice('Choose a saved game',menu_items,False)
  444. if choice == 'exit':
  445. master_loop = False
  446. run = False
  447. return('exit')
  448. if choice < 5:
  449. save_path = path + os.sep + 'SAVE' + os.sep + 'World' + str(choice)
  450. playing = True
  451. run = False
  452. elif choice == 5:
  453. menu_items_erase = []
  454. for d in range(0,5):
  455. menu_items_erase.append(menu_items[d])
  456. menu_items_erase.append('~~BACK~~')
  457. choice2 = screen.get_choice('Choose a game to erase',menu_items_erase,False,'Warning')
  458. if choice2 < 5:
  459. save_path = path + os.sep + 'SAVE' + os.sep + 'World' + str(choice2)
  460. try:
  461. choice3 = screen.get_choice('Are you sure?',('No','Yes'),False,'Warning')
  462. if choice3 == 1:
  463. h = ('world.data','time.data','player.data','gods.data')
  464. for i in h:
  465. p = save_path + os.sep + i
  466. os.remove(p)
  467. except:
  468. None
  469. elif choice == 6:
  470. run = False
  471. def save_tmp_png(self):
  472. x = player.pos[0]
  473. if x-10 < 0:
  474. x += -1*(x-11)
  475. elif x+10 > max_map_size-2:
  476. x -= 10
  477. y = player.pos[1]
  478. if y-10 < 0:
  479. y += -1*(y-11)
  480. elif y+10 > max_map_size-2:
  481. y -= 10
  482. z = player.pos[2]
  483. s = pygame.Surface((480,360))
  484. for yy in range(-5,10):
  485. for xx in range(-7,8):
  486. t_pos = world.maplist[z][player.on_map].tilemap[y+yy][x+xx].tile_pos
  487. t_replace = world.maplist[z][player.on_map].tilemap[y+yy][x+xx].replace
  488. if t_replace == None:
  489. s.blit(gra_files.gdic['tile32'][t_pos[1]][t_pos[0]],((xx+7)*32,(yy+5)*32))
  490. else:
  491. try:
  492. #render the replaced tile under the replacing one. eg.: for stacks
  493. s.blit(gra_files.gdic['tile32'][t_replace.tile_pos[1]][t_replace.tile_pos[0]],((xx+7)*32,(yy+5)*32))
  494. s.blit(gra_files.gdic['tile32'][t_pos[1]][t_pos[0]],((xx+7)*32,(yy+5)*32))
  495. except:
  496. None
  497. if home_save == False:
  498. tmp_save_path = basic_path +os.sep + 'GRAPHIC' + os.sep + 'DISPLAY' + os.sep + 'tmp.png'
  499. else:
  500. tmp_save_path = os.path.expanduser('~') + os.sep + '.config' + os.sep + 'RogueBox-Adventures' + os.sep + 'tmp.png'
  501. pygame.image.save(s,tmp_save_path)
  502. def re_init(self): # For changing screenmode
  503. options_path = save_path.replace(os.sep + 'World0','')
  504. if game_options.screenmode == 2 and cheat_mode == True:
  505. game_options.screenmode = 0
  506. mode = game_options.screenmode
  507. if self.win_mode < 2:
  508. mode += 1
  509. else:
  510. mode = 0
  511. if mode == 2 and cheat_mode == True:
  512. mode = 0
  513. game_options.screenmode = mode
  514. save_options(game_options,options_path,os.sep)
  515. self.__init__(game_options.screenmode,False)
  516. def draw_player(self):
  517. s = pygame.Surface((32,32))
  518. s.fill((255,0,255))
  519. if player.inventory.wearing['Background'] != player.inventory.nothing:
  520. 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))
  521. skinstring = 'SKIN_' + player.gender + '_' + str(player.style +1)
  522. s.blit(gra_files.gdic['char'][skinstring],(0,0))
  523. if player.inventory.wearing['Clothing'] == player.inventory.nothing:
  524. underwear_string = player.gender + '_underwear'
  525. s.blit(gra_files.gdic['char'][underwear_string],(0,0))
  526. try:
  527. render_hair = (player.inventory.wearing['Hat'].override_hair == False)
  528. except:
  529. render_hair = True
  530. if player.inventory.wearing['Head'] == player.inventory.nothing and render_hair:
  531. hairstring = 'HAIR_' + player.gender + '_' + str(player.style +1)
  532. s.blit(gra_files.gdic['char'][hairstring],(0,0))
  533. if player.inventory.wearing['Hat'] != player.inventory.nothing:
  534. 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))
  535. else:
  536. if player.inventory.wearing['Hat'] == player.inventory.nothing:
  537. if player.inventory.wearing['Head'] != player.inventory.nothing:
  538. helmetstring = player.gender + '_' + player.inventory.wearing['Head'].material + '_' + player.inventory.wearing['Head'].classe
  539. s.blit(gra_files.gdic['char'][helmetstring],(0,0))
  540. else:
  541. if render_hair == True:
  542. hairstring = 'HAIR_' + player.gender + '_' + str(player.style +1)
  543. s.blit(gra_files.gdic['char'][hairstring],(0,0))
  544. 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))
  545. if player.inventory.wearing['Clothing'] == player.inventory.nothing:
  546. if player.inventory.wearing['Body'] != player.inventory.nothing:
  547. armorstring = player.gender + '_' + player.inventory.wearing['Body'].material + '_' + player.inventory.wearing['Body'].classe
  548. s.blit(gra_files.gdic['char'][armorstring],(0,0))
  549. if player.inventory.wearing['Legs'] != player.inventory.nothing:
  550. cuissestring = player.gender + '_' + player.inventory.wearing['Legs'].material + '_' + player.inventory.wearing['Legs'].classe
  551. s.blit(gra_files.gdic['char'][cuissestring],(0,0))
  552. if player.inventory.wearing['Feet'] != player.inventory.nothing:
  553. shoestring = player.gender + '_' + player.inventory.wearing['Feet'].material + '_' + player.inventory.wearing['Feet'].classe
  554. s.blit(gra_files.gdic['char'][shoestring],(0,0))
  555. else:
  556. 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))
  557. if player.inventory.wearing['Hold(R)'] != player.inventory.nothing:
  558. weaponstring = 'WEAPONS_' + player.inventory.wearing['Hold(R)'].material + '_' + player.inventory.wearing['Hold(R)'].classe
  559. s.blit(gra_files.gdic['char'][weaponstring],(0,0))
  560. if player.inventory.wearing['Hold(L)'] != player.inventory.nothing:
  561. weaponstring = 'WEAPONS_' + player.inventory.wearing['Hold(L)'].material + '_' + player.inventory.wearing['Hold(L)'].classe
  562. s.blit(gra_files.gdic['char'][weaponstring],(0,0))
  563. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]][player.pos[0]].move_group == 'low_liquid':
  564. help_s = pygame.Surface((32,5))
  565. help_s.fill((255,0,255))
  566. s.blit(help_s,(0,27))
  567. elif world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]][player.pos[0]].move_group == 'swim':
  568. help_s = pygame.Surface((32,13))
  569. help_s.fill((255,0,255))
  570. s.blit(help_s,(0,19))
  571. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  572. return s
  573. def draw_tile(self,on_map,x,y,z,visible):
  574. s = pygame.Surface((32,32))
  575. s.fill((48,48,48))
  576. if x > max_map_size-1 or y > max_map_size-1 or x < 0 or y < 0:
  577. return s
  578. if world.maplist[z][on_map].known[y][x] == 0:
  579. s.blit(gra_files.gdic['tile32'][0][3],(0,0))
  580. else:
  581. if world.maplist[z][on_map].tilemap[y][x].replace != None:
  582. old_tile = world.maplist[z][on_map].tilemap[y][x]
  583. new_tile = world.maplist[z][on_map].tilemap[y][x]
  584. run = True
  585. while run:
  586. new_tile = old_tile.replace
  587. if new_tile != None:
  588. old_tile = new_tile
  589. else:
  590. run = False
  591. if len(old_tile.tile_pos) > 2:
  592. if time.minute%2 == 0:
  593. s.blit(gra_files.gdic['tile32'][old_tile.tile_pos[1]][old_tile.tile_pos[0]],(0,0))
  594. else:
  595. s.blit(gra_files.gdic['tile32'][old_tile.tile_pos[3]][old_tile.tile_pos[2]],(0,0))
  596. else:
  597. s.blit(gra_files.gdic['tile32'][old_tile.tile_pos[1]][old_tile.tile_pos[0]],(0,0))
  598. if len(world.maplist[z][on_map].tilemap[y][x].tile_pos) > 2:
  599. if time.minute%2 == 0:
  600. 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))
  601. else:
  602. 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))
  603. else:
  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. if visible == False:
  606. s.blit(gra_files.gdic['display'][6],(0,0))
  607. if world.maplist[z][on_map].npcs[y][x] != 0:
  608. s.blit(self.draw_monster(x,y,z,on_map,visible),(0,0))
  609. return s
  610. def draw_monster(self,x,y,z,on_map,visible):
  611. s = pygame.Surface((32,32))
  612. s.fill((255,0,255))
  613. if visible == True:
  614. pos = world.maplist[z][on_map].npcs[y][x].sprite_pos
  615. s.blit(gra_files.gdic['monster'][pos[1]][pos[0]],(0,0))
  616. if world.maplist[z][on_map].tilemap[y][x].move_group == 'low_liquid':
  617. help_s = pygame.Surface((32,5))
  618. help_s.fill((255,0,255))
  619. s.blit(help_s,(0,27))
  620. elif world.maplist[z][on_map].tilemap[y][x].move_group == 'swim':
  621. help_s = pygame.Surface((32,13))
  622. help_s.fill((255,0,255))
  623. s.blit(help_s,(0,19))
  624. if world.maplist[z][on_map].npcs[y][x].move_border == 10:
  625. None
  626. elif world.maplist[z][on_map].npcs[y][x].AI_style == 'ignore':
  627. s.blit(gra_files.gdic['display'][28],(0,0))
  628. lvl = str(world.maplist[z][on_map].npcs[y][x].lvl)
  629. if len(lvl) == 1:
  630. lvl = '0'+lvl
  631. elif len(lvl) > 2:
  632. lvl = lvl[0]+'+'
  633. s.blit(gra_files.gdic['num'][lvl[0]],(0,6))
  634. s.blit(gra_files.gdic['num'][lvl[1]],(0,14))
  635. elif world.maplist[z][on_map].npcs[y][x].AI_style == 'flee':
  636. s.blit(gra_files.gdic['display'][29],(0,0))
  637. lvl = str(world.maplist[z][on_map].npcs[y][x].lvl)
  638. if len(lvl) == 1:
  639. lvl = '0'+lvl
  640. elif len(lvl) > 2:
  641. lvl = lvl[0]+'+'
  642. s.blit(gra_files.gdic['num'][lvl[0]],(0,6))
  643. s.blit(gra_files.gdic['num'][lvl[1]],(0,14))
  644. else:
  645. s.blit(gra_files.gdic['display'][30],(0,0))
  646. lvl = str(world.maplist[z][on_map].npcs[y][x].lvl)
  647. if len(lvl) == 1:
  648. lvl = '0'+lvl
  649. elif len(lvl) > 2:
  650. lvl = lvl[0]+'+'
  651. s.blit(gra_files.gdic['num'][lvl[0]],(0,6))
  652. s.blit(gra_files.gdic['num'][lvl[1]],(0,14))
  653. if world.maplist[z][on_map].npcs[y][x].move_border > 10:
  654. s.blit(gra_files.gdic['display'][69],(0,0))
  655. else:
  656. 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':
  657. pos = world.maplist[z][on_map].npcs[y][x].sprite_pos
  658. s.blit(gra_files.gdic['monster'][pos[1]][pos[0]],(0,0))
  659. else:
  660. coin = random.randint(0,1)
  661. if coin == 1:
  662. s.blit(gra_files.gdic['display'][7],(0,0))
  663. else:
  664. s.blit(gra_files.gdic['display'][6],(0,0))
  665. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  666. if world.maplist[z][on_map].npcs[y][x].quest_state != 'None':
  667. s.blit(gra_files.gdic['display'][59],(0,0))
  668. return s
  669. def generate_light_effect(self):
  670. if player.buffs.get_buff('berzerk') > 0:
  671. y = 3
  672. elif player.buffs.get_buff('nightvision') > 0:
  673. y = 2
  674. elif player.pos[2] > 0:
  675. y = 1
  676. else:
  677. y= 0
  678. x = time.hour
  679. if player.buffs.get_buff('berzerk') > 0:
  680. alpha = 135
  681. elif player.buffs.get_buff('nightvision') > 0:
  682. alpha = 60
  683. elif player.pos[2] == 0:
  684. if time.hour == 12:
  685. alpha = 0
  686. elif time.hour < 12:
  687. alpha = 60-(time.hour*5)
  688. elif time.hour > 12:
  689. alpha = 0+((time.hour-12)*5)
  690. else:
  691. alpha = 135
  692. light_color = gra_files.gdic['lightmap'].get_at((x,y))
  693. s = pygame.Surface((640,360))
  694. s.fill(light_color)
  695. if player.buffs.get_buff('light') > 0 and player.buffs.get_buff('berzerk') == 0:
  696. pygame.draw.circle(s,(255,0,255),[254,197],120,0)
  697. help_tile = pygame.Surface((32,32))
  698. help_tile.fill(light_color)
  699. fov = world.maplist[player.pos[2]][player.on_map].check_fov(player.pos[0],player.pos[1],6)
  700. for y in range(0,len(fov)-1):
  701. for x in range(0,len(fov[y])-1):
  702. if fov[y][x] == 0:
  703. s.blit(help_tile,(x*32,y*32))
  704. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  705. s.set_alpha(alpha)
  706. return s
  707. def render(self,mes_num, simulate = False, photo = False):
  708. radius = 6
  709. if player.pos[2] > 0:
  710. radius = 2
  711. elif player.pos[2] == 0:
  712. if time.hour > 22 or time.hour < 4:
  713. radius = 2
  714. elif time.hour > 21 or time.hour < 5:
  715. radius = 3
  716. elif time.hour > 20 or time.hour < 6:
  717. radius = 4
  718. elif time.hour > 19 or time.hour < 7:
  719. radius = 5
  720. if player.buffs.get_buff('light') > 0 or player.buffs.get_buff('nightvision'):
  721. radius = 6
  722. if player.buffs.get_buff('blind') > 0:
  723. radius = 0
  724. s = pygame.Surface((640,360))
  725. test = message.sget()
  726. s.fill((48,48,48)) #paint it grey(to clear the screen)
  727. start_pos_x = 240 #the center of the main map view
  728. start_pos_y = 180
  729. ymin = player.pos[1]-6
  730. ymax = player.pos[1]+6
  731. xmin = player.pos[0]-8
  732. xmax = player.pos[0]+7
  733. ry = 0
  734. fow = world.maplist[player.pos[2]][player.on_map].check_fov(player.pos[0],player.pos[1],radius)
  735. for y in range(ymin,ymax):
  736. rx = 0
  737. for x in range(xmin,xmax):
  738. s.blit(screen.draw_tile(player.on_map,x,y,player.pos[2],fow[ry][rx]),(rx*32,ry*32))
  739. if x == player.pos[0] and y == player.pos[1]:
  740. s.blit(screen.draw_player(),(rx*32,ry*32))
  741. player_pos_help = (x,y)
  742. rx+=1
  743. ry+=1
  744. s.blit(self.render_hits(),(0,0))
  745. s.blit(screen.generate_light_effect(),(0,0))
  746. if photo == True:
  747. if low_res == False:
  748. photo_help = pygame.Surface((480,360))
  749. photo_help.blit(s,(0,0))
  750. s = photo_help
  751. else:
  752. photo_help = pygame.Surface((320,240))
  753. photo_help.blit(s,(0,0))
  754. s = photo_help
  755. return s
  756. if self.fire_mode == 0:
  757. 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:
  758. s.blit(gra_files.gdic['display'][0],(0,0)) #render gui
  759. else:
  760. s.blit(gra_files.gdic['display'][25],(0,0)) #render gui_warning
  761. elif self.fire_mode == 1:
  762. s.blit(gra_files.gdic['display'][10],(0,0))
  763. 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))
  764. else:
  765. 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:
  766. s.blit(gra_files.gdic['display'][0],(0,0)) #render gui
  767. else:
  768. s.blit(gra_files.gdic['display'][25],(0,0)) #render gui_warning
  769. 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))
  770. #render tool info
  771. #1. Axe
  772. if player.inventory.wearing['Axe'] == player.inventory.nothing:
  773. s.blit(gra_files.gdic['display'][44],(0,39))
  774. else:
  775. s.blit(gra_files.gdic['display'][46],(0,39))
  776. axestring = 'WEAPONS_' + player.inventory.wearing['Axe'].material + '_' + player.inventory.wearing['Axe'].classe
  777. s.blit(gra_files.gdic['char'][axestring],(0,39))
  778. s.blit(gra_files.gdic['display'][47],(0,39))
  779. axe_state = (15*player.inventory.wearing['Axe'].state)/100
  780. help_sur = pygame.Surface((axe_state,1))
  781. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  782. s.blit(help_sur,(10,67))
  783. #2. Pickaxe
  784. if player.inventory.wearing['Pickaxe'] == player.inventory.nothing:
  785. s.blit(gra_files.gdic['display'][45],(16,39))
  786. else:
  787. s.blit(gra_files.gdic['display'][46],(16,39))
  788. pickaxestring = 'WEAPONS_' + player.inventory.wearing['Pickaxe'].material + '_' + player.inventory.wearing['Pickaxe'].classe
  789. s.blit(gra_files.gdic['char'][pickaxestring],(16,39))
  790. s.blit(gra_files.gdic['display'][47],(16,39))
  791. pickaxe_state = (15*player.inventory.wearing['Pickaxe'].state)/100
  792. help_sur = pygame.Surface((pickaxe_state,1))
  793. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  794. s.blit(help_sur,(26,67))
  795. #3. Melee weapon
  796. if player.inventory.wearing['Hold(R)'] == player.inventory.nothing:
  797. s.blit(gra_files.gdic['display'][52],(32,39))
  798. else:
  799. s.blit(gra_files.gdic['display'][46],(32,39))
  800. melee_string = 'WEAPONS_' + player.inventory.wearing['Hold(R)'].material + '_' + player.inventory.wearing['Hold(R)'].classe
  801. if player.inventory.wearing['Hold(R)'].classe != 'spear':
  802. s.blit(gra_files.gdic['char'][melee_string],(32,39))
  803. else:
  804. h_sur = pygame.Surface((32,19))
  805. h_sur.fill((255,0,255))
  806. h_sur.blit(gra_files.gdic['char'][melee_string],(0,0))
  807. h_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  808. h_sur = h_sur.convert_alpha()
  809. s.blit(h_sur,(39,48))
  810. s.blit(gra_files.gdic['display'][47],(32,39))
  811. melee_state = (15*player.inventory.wearing['Hold(R)'].state)/100
  812. help_sur = pygame.Surface((melee_state,1))
  813. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  814. s.blit(help_sur,(42,67))
  815. #4. Magic weapon
  816. if player.inventory.wearing['Hold(L)'] == player.inventory.nothing:
  817. s.blit(gra_files.gdic['display'][53],(48,39))
  818. else:
  819. s.blit(gra_files.gdic['display'][46],(48,39))
  820. magic_string = 'WEAPONS_' + player.inventory.wearing['Hold(L)'].material + '_' + player.inventory.wearing['Hold(L)'].classe
  821. if player.inventory.wearing['Hold(L)'].classe != 'rune staff':
  822. s.blit(gra_files.gdic['char'][magic_string],(42,39))
  823. else:
  824. h_sur = pygame.Surface((32,19))
  825. h_sur.fill((255,0,255))
  826. h_sur.blit(gra_files.gdic['char'][magic_string],(0,0))
  827. h_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  828. h_sur = h_sur.convert_alpha()
  829. s.blit(h_sur,(42,48))
  830. s.blit(gra_files.gdic['display'][47],(48,39))
  831. magic_state = (15*player.inventory.wearing['Hold(L)'].state)/100
  832. help_sur = pygame.Surface((magic_state,1))
  833. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  834. s.blit(help_sur,(58,67))
  835. #5. Necklace
  836. if player.inventory.wearing['Neck'] == player.inventory.nothing:
  837. s.blit(gra_files.gdic['display'][40],(64,39))
  838. else:
  839. s.blit(gra_files.gdic['display'][46],(64,39))
  840. necklacestring = 'WEAPONS_' + player.inventory.wearing['Neck'].material + '_' + player.inventory.wearing['Neck'].classe
  841. s.blit(gra_files.gdic['char'][necklacestring],(64,39))
  842. s.blit(gra_files.gdic['display'][47],(64,39))
  843. necklace_state = (15*player.inventory.wearing['Neck'].state)/100
  844. help_sur = pygame.Surface((necklace_state,1))
  845. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  846. s.blit(help_sur,(74,67))
  847. #6. Helmet
  848. if player.inventory.wearing['Head'] == player.inventory.nothing:
  849. s.blit(gra_files.gdic['display'][54],(0,54))
  850. else:
  851. s.blit(gra_files.gdic['display'][46],(0,54))
  852. helmet_string = player.gender + '_' + player.inventory.wearing['Head'].material + '_' + player.inventory.wearing['Head'].classe
  853. h_sur = pygame.Surface((32,32))
  854. h_sur.fill((255,0,255))
  855. h_sur.blit(gra_files.gdic['char'][helmet_string],(0,0))
  856. pygame.draw.rect(h_sur,(255,0,255),(0,0,10,32),0)
  857. pygame.draw.rect(h_sur,(255,0,255),(0,0,32,4),0)
  858. pygame.draw.rect(h_sur,(255,0,255),(25,0,7,32),0)
  859. h_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  860. h_sur = h_sur.convert_alpha()
  861. s.blit(h_sur,(0,65))
  862. s.blit(gra_files.gdic['display'][47],(0,54))
  863. helmet_state = (15*player.inventory.wearing['Head'].state)/100
  864. help_sur = pygame.Surface((helmet_state,1))
  865. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  866. s.blit(help_sur,(10,82))
  867. #7. Armor
  868. if player.inventory.wearing['Body'] == player.inventory.nothing:
  869. s.blit(gra_files.gdic['display'][55],(16,54))
  870. else:
  871. s.blit(gra_files.gdic['display'][46],(16,54))
  872. armor_string = player.gender + '_' + player.inventory.wearing['Body'].material + '_' + player.inventory.wearing['Body'].classe
  873. h_sur = pygame.Surface((32,32))
  874. h_sur.fill((255,0,255))
  875. h_sur.blit(gra_files.gdic['char'][armor_string],(0,0))
  876. pygame.draw.rect(h_sur,(255,0,255),(0,0,10,32),0)
  877. pygame.draw.rect(h_sur,(255,0,255),(25,0,7,32),0)
  878. h_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  879. h_sur = h_sur.convert_alpha()
  880. s.blit(h_sur,(16,55))
  881. s.blit(gra_files.gdic['display'][47],(16,54))
  882. armor_state = (15*player.inventory.wearing['Body'].state)/100
  883. help_sur = pygame.Surface((armor_state,1))
  884. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  885. s.blit(help_sur,(26,82))
  886. #8. Cuisse
  887. if player.inventory.wearing['Legs'] == player.inventory.nothing:
  888. s.blit(gra_files.gdic['display'][56],(32,54))
  889. else:
  890. s.blit(gra_files.gdic['display'][46],(32,54))
  891. cuisse_string = player.gender + '_' + player.inventory.wearing['Legs'].material + '_' + player.inventory.wearing['Legs'].classe
  892. s.blit(gra_files.gdic['char'][cuisse_string],(32,50))
  893. s.blit(gra_files.gdic['display'][47],(32,54))
  894. cuisse_state = (15*player.inventory.wearing['Legs'].state)/100
  895. help_sur = pygame.Surface((cuisse_state,1))
  896. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  897. s.blit(help_sur,(42,82))
  898. #9. Shoes
  899. if player.inventory.wearing['Feet'] == player.inventory.nothing:
  900. s.blit(gra_files.gdic['display'][57],(48,54))
  901. else:
  902. s.blit(gra_files.gdic['display'][46],(48,54))
  903. shoes_string = player.gender + '_' + player.inventory.wearing['Feet'].material + '_' + player.inventory.wearing['Feet'].classe
  904. s.blit(gra_files.gdic['char'][shoes_string],(49,46))
  905. s.blit(gra_files.gdic['display'][47],(48,54))
  906. shoes_state = (15*player.inventory.wearing['Feet'].state)/100
  907. help_sur = pygame.Surface((shoes_state,1))
  908. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  909. s.blit(help_sur,(58,82))
  910. #10. Ring
  911. if player.inventory.wearing['Hand'] == player.inventory.nothing:
  912. s.blit(gra_files.gdic['display'][39],(64,54))
  913. else:
  914. s.blit(gra_files.gdic['display'][46],(64,54))
  915. ring_string = 'WEAPONS_' + player.inventory.wearing['Hand'].material + '_' + player.inventory.wearing['Hand'].classe
  916. s.blit(gra_files.gdic['char'][ring_string],(64,54))
  917. s.blit(gra_files.gdic['display'][47],(64,54))
  918. ring_state = (15*player.inventory.wearing['Hand'].state)/100
  919. help_sur = pygame.Surface((ring_state,1))
  920. help_sur.blit(gra_files.gdic['display'][48],(0,0))
  921. s.blit(help_sur,(74,82))
  922. #render icons
  923. #1. Use
  924. 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:
  925. s.blit(gra_files.gdic['display'][32],(0,161))
  926. s.blit(gra_files.gdic['display'][34],(0,161))
  927. else:
  928. s.blit(gra_files.gdic['display'][31],(0,161))
  929. s.blit(gra_files.gdic['display'][33],(0,161))
  930. use_string = '['+key_name['e']+']action'
  931. use_image1 = self.font.render(use_string,1,(0,0,0))
  932. use_image2 = self.font.render(use_string,1,(255,255,255))
  933. s.blit(use_image1,(36,173))
  934. s.blit(use_image2,(34,173))
  935. #2. Fire
  936. if player.inventory.wearing['Hold(L)'] == player.inventory.nothing or player.mp < 2:
  937. s.blit(gra_files.gdic['display'][32],(0,129))
  938. s.blit(gra_files.gdic['display'][36],(0,129))
  939. else:
  940. s.blit(gra_files.gdic['display'][31],(0,129))
  941. s.blit(gra_files.gdic['display'][35],(0,129))
  942. if self.fire_mode == False:
  943. fire_string = '['+key_name['f']+']fire'
  944. else:
  945. fire_string = '['+key_name['x']+']cancel'
  946. fire_image1 = self.font.render(fire_string,1,(0,0,0))
  947. fire_image2 = self.font.render(fire_string,1,(255,255,255))
  948. s.blit(fire_image1,(36,141))
  949. s.blit(fire_image2,(34,141))
  950. #4.Focus
  951. s.blit(gra_files.gdic['display'][32],(0,97))#65
  952. try:
  953. focus_state = (32*player.mp/player.attribute.max_mp)
  954. except:
  955. focus_state = 1
  956. help_sur = pygame.Surface((focus_state,32))
  957. help_sur.fill((255,0,255))
  958. help_sur.blit(gra_files.gdic['display'][31],(0,0))
  959. help_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  960. help_sur = help_sur.convert_alpha()
  961. s.blit(help_sur,(0,97))
  962. if player.mp < player.attribute.max_mp:
  963. s.blit(gra_files.gdic['display'][38],(0,97))
  964. focus_string = 'unfocused'
  965. else:
  966. s.blit(gra_files.gdic['display'][37],(0,97))
  967. focus_string = 'focused'
  968. focus_image1 = self.font.render(focus_string,1,(0,0,0))
  969. focus_image2 = self.font.render(focus_string,1,(255,255,255))
  970. s.blit(focus_image1,(36,109))#77
  971. s.blit(focus_image2,(34,109))
  972. # render messages
  973. if low_res == False:
  974. mes_pos_y = 335
  975. else:
  976. mes_pos_y = 225
  977. mlist = test
  978. for c in range(0,5):
  979. shadow_image = self.font.render(mlist[c],1,(0,0,0))
  980. text_image = self.font.render(mlist[c],1,(255,255,255))
  981. s.blit(shadow_image,(2,mes_pos_y-(c*10)))
  982. s.blit(text_image,(0,mes_pos_y-(c*10)))
  983. #render lvl info
  984. lvl_string = str(player.lvl)
  985. if len(lvl_string) == 1:
  986. lvl_string = '0'+lvl_string
  987. lvl_image = self.font.render(lvl_string,1,(255,255,255))
  988. s.blit(lvl_image,(153,48))
  989. bar_length = 1 + ((319/100)*player.xp)
  990. xp_surface = pygame.Surface((bar_length,64))
  991. xp_surface.fill((255,0,255))
  992. xp_surface.blit(gra_files.gdic['display'][19],(0,0))
  993. xp_surface.set_colorkey((255,0,255),pygame.RLEACCEL)
  994. xp_surface = xp_surface.convert_alpha()
  995. s.blit(xp_surface,(0,0))
  996. if game_options.mousepad == 1:
  997. if self.fire_mode == 0:
  998. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  999. else:
  1000. s.blit(gra_files.gdic['display'][9],(480,0))
  1001. else:
  1002. s_help = pygame.Surface((160,360))
  1003. s_help.fill((48,48,48))
  1004. s.blit(s_help,(480,0))
  1005. #render buffs
  1006. buffs = player.buffs.sget()
  1007. if low_res == False:
  1008. posx = 388
  1009. posy = 10
  1010. else:
  1011. posx = 228
  1012. posy = 75
  1013. for i in buffs:
  1014. if i != ' ':
  1015. buff_shadow = self.font.render(i,1,(0,0,0))
  1016. s.blit(buff_shadow,(posx+2,posy))
  1017. buff_image = self.font.render(i,1,(200,200,200))
  1018. s.blit(buff_image,(posx,posy))
  1019. else:
  1020. None
  1021. posy += 20
  1022. #render date
  1023. date_string = time.sget()
  1024. posx = 235
  1025. posy = 10
  1026. date_image = self.font.render(date_string[0],1,(0,0,0))
  1027. s.blit(date_image,(posx,posy))
  1028. posy = 20
  1029. time_image = self.font.render(date_string[1],1,(0,0,0))
  1030. s.blit(time_image,(posx,posy))
  1031. #render player info
  1032. #lp
  1033. lp_string = str(player.lp) + '/' + str(player.attribute.max_lp)
  1034. posx = 13
  1035. posy = 12
  1036. if player.lp < 4:
  1037. lp_image = self.font.render(lp_string,1,(200,0,0))
  1038. else:
  1039. lp_image = self.font.render(lp_string,1,(0,0,0))
  1040. s.blit(lp_image,(posx,posy))
  1041. #hunger
  1042. hunger_percent = int((100 * player.attribute.hunger) / player.attribute.hunger_max)
  1043. hunger_string = str(hunger_percent) + '%'
  1044. posx = 75
  1045. posy = 12
  1046. if hunger_percent < 11:
  1047. hunger_image = self.font.render(hunger_string,1,(200,0,0))
  1048. else:
  1049. hunger_image = self.font.render(hunger_string,1,(0,0,0))
  1050. s.blit(hunger_image,(posx,posy))
  1051. #trirst
  1052. thirst_percent = int((100 * player.attribute.thirst) / player.attribute.thirst_max)
  1053. thirst_string = str(thirst_percent) + '%'
  1054. posx = 125
  1055. posy = 12
  1056. if thirst_percent < 11:
  1057. thirst_image = self.font.render(thirst_string,1,(200,0,0))
  1058. else:
  1059. thirst_image = self.font.render(thirst_string,1,(0,0,0))
  1060. s.blit(thirst_image,(posx,posy))
  1061. #tiredness
  1062. tiredness_percent = int((100 * player.attribute.tiredness) / player.attribute.tiredness_max)
  1063. tiredness_string = str(tiredness_percent) + '%'
  1064. posx = 180
  1065. posy = 12
  1066. if tiredness_percent < 11:
  1067. tiredness_image = self.font.render(tiredness_string,1,(200,0,0))
  1068. else:
  1069. tiredness_image = self.font.render(tiredness_string,1,(0,0,0))
  1070. s.blit(tiredness_image,(posx,posy))
  1071. if game_options.mousepad == 0:
  1072. s_help = pygame.Surface((640,360))
  1073. s_help.fill((48,48,48))
  1074. s_help.blit(s,(80,0))
  1075. s = s_help
  1076. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1077. self.screen.blit(s,(0,0))
  1078. if simulate == False:
  1079. pygame.display.flip()
  1080. else:
  1081. return s
  1082. if test[1] == '~*~':
  1083. return True
  1084. else:
  1085. return False
  1086. def render_load(self,num,progress=None):
  1087. s = pygame.Surface((640,360))
  1088. s.fill((48,48,48)) #paint it grey(to clear the screen)
  1089. if num == 0:
  1090. string = 'Looking for saved data... '
  1091. elif num == 1:
  1092. string = 'Loading world data...'
  1093. elif num == 2:
  1094. string = 'Nothing found...'
  1095. elif num == 3:
  1096. string = 'Generate overworld...'
  1097. elif num == 4:
  1098. string = 'Generate caves...'
  1099. elif num == 5:
  1100. string = 'Saving...'
  1101. elif num == 6:
  1102. string = 'Loading time data...'
  1103. elif num == 7:
  1104. string = 'Loading player data...'
  1105. elif num == 8:
  1106. string = 'Set time...'
  1107. elif num == 9:
  1108. string = 'Generate player...'
  1109. elif num == 10:
  1110. string = 'Making time related changes...'
  1111. elif num == 11:
  1112. string = 'Something has gone wrong...'
  1113. elif num == 12:
  1114. string = 'Zzzzzzzzzz'
  1115. elif num == 13:
  1116. string = 'Generate deus ex machina...'
  1117. elif num == 14:
  1118. string = 'Loading deus ex machina...'
  1119. elif num == 15:
  1120. string = 'Generate grot...'
  1121. elif num == 16:
  1122. string = 'Generate elfish fortress...'
  1123. elif num == 17:
  1124. string = 'Generate orcish mines...'
  1125. elif num == 18:
  1126. string = 'Generate desert...'
  1127. elif num == 19:
  1128. string = 'Initialize level...'
  1129. elif num == 20:
  1130. string = 'Please use run.py/run.exe'
  1131. ######add more here
  1132. if low_res == False:
  1133. posx = 150
  1134. posy = 200
  1135. else:
  1136. posx=50
  1137. posy= 100
  1138. image = self.font.render(string,1,(255,255,255))
  1139. s.blit(image,(posx,posy))
  1140. if progress != None:
  1141. s.blit(gra_files.gdic['display'][20],(posx-50,posy+20))
  1142. help_sur = pygame.Surface((((progress*320)/100),12))
  1143. help_sur.fill((255,0,255))
  1144. help_sur.blit(gra_files.gdic['display'][21],(0,0))
  1145. help_sur.set_colorkey((255,0,255),pygame.RLEACCEL)
  1146. help_sur = help_sur.convert_alpha()
  1147. s.blit(help_sur,(posx-50,posy+20))
  1148. if low_res == False:
  1149. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1150. self.screen.blit(s,(0,0))
  1151. pygame.display.flip()
  1152. def render_built(self,xmin,xmax,ymin,ymax,style):
  1153. start_pos_x = 256 #the center of the main map view
  1154. start_pos_y = 192
  1155. price = 0
  1156. bg = self.render(0, True)
  1157. s = pygame.Surface((640,360))
  1158. s.fill((255,0,255))
  1159. if style == 'Room':
  1160. build_total = True
  1161. for y in range (-ymin,ymax+1):
  1162. for x in range (-xmin,xmax+1):
  1163. 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:
  1164. built_here = 1
  1165. price += 2
  1166. elif world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].civilisation == True:
  1167. built_here = 2
  1168. price += 1
  1169. else:
  1170. built_here = 0
  1171. if world.maplist[player.pos[2]][player.on_map].npcs[player.pos[1]+y][player.pos[0]+x] != 0:
  1172. built_here = 0
  1173. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].build_here == False:
  1174. built_here = 0
  1175. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+y][player.pos[0]+x].build_here == False:
  1176. if built_here == 1:
  1177. price -= 2
  1178. elif built_here == 2:
  1179. price -= 1
  1180. built_here = 0
  1181. if built_here == 0:
  1182. build_total = False
  1183. if build_total == False:
  1184. price = 0
  1185. for y in range (-ymin,ymax+1):
  1186. for x in range (-xmin,xmax+1):
  1187. if build_total != 0:
  1188. if x == xmax or x == -xmin or y == ymax or y == -ymin:
  1189. if x == xmax or x == -xmin:
  1190. if built_here == 1:
  1191. s.blit(gra_files.gdic['built'][1],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_true here
  1192. elif built_here == 2:
  1193. s.blit(gra_files.gdic['built'][6],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_over here
  1194. elif y == ymax or y == -ymin:
  1195. if built_here == 1:
  1196. s.blit(gra_files.gdic['built'][1],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_true here
  1197. elif built_here == 2:
  1198. s.blit(gra_files.gdic['built'][6],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_over here
  1199. else:
  1200. if built_here == 1:
  1201. s.blit(gra_files.gdic['built'][5],(start_pos_x+(x*32),start_pos_y+(y*32))) #floor_true here
  1202. elif built_here == 2:
  1203. s.blit(gra_files.gdic['built'][7],(start_pos_x+(x*32),start_pos_y+(y*32))) #floor_over
  1204. else:
  1205. if x == xmax or x == -xmin or y == ymax or y == -ymin:
  1206. if x == xmax or x == -xmin:
  1207. s.blit(gra_files.gdic['built'][0],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_false here
  1208. elif y == ymax or y == -ymin:
  1209. s.blit(gra_files.gdic['built'][0],(start_pos_x+(x*32),start_pos_y+(y*32))) #wall_false here
  1210. else:
  1211. s.blit(gra_files.gdic['built'][4],(start_pos_x+(x*32),start_pos_y+(y*32))) #floor_false here
  1212. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1213. # render mode name
  1214. name = '~Build Room~'
  1215. name_image = self.font.render(name,1,(255,255,255))
  1216. posx = 0
  1217. posy = 0
  1218. s.blit(name_image,(posx,posy))
  1219. # render wood needed
  1220. wood_need = int(price/2)
  1221. if wood_need == 0 and price != 0:
  1222. wood_need = 1
  1223. wood_string = 'Wood: ' + str(wood_need) + '(' + str(player.inventory.materials.wood) + ')'
  1224. posx = 0
  1225. posy = 15
  1226. if wood_need <= player.inventory.materials.wood:
  1227. wood_image = self.font.render(wood_string,1,(255,255,255))
  1228. else:
  1229. wood_image = self.font.render(wood_string,1,(200,0,0))
  1230. s.blit(wood_image,(posx,posy))
  1231. # render stone needed
  1232. stone_need = int(price/2)
  1233. if stone_need == 0 and price != 0:
  1234. stone_need = 1
  1235. stone_string = 'Stone: ' + str(stone_need) + '(' + str(player.inventory.materials.stone) + ')'
  1236. posx = 160
  1237. posy = 15
  1238. if stone_need <= player.inventory.materials.stone:
  1239. stone_image = self.font.render(stone_string,1,(255,255,255))
  1240. else:
  1241. stone_image = self.font.render(stone_string,1,(200,0,0))
  1242. s.blit(stone_image,(posx,posy))
  1243. # render info line
  1244. info_string_0 = '['+key_name['wasd']+']change Size'
  1245. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']BUILT!'
  1246. posx = 0
  1247. posy = 30
  1248. info_image = self.font.render(info_string_0,1,(255,255,255))
  1249. s.blit(info_image,(posx,posy))
  1250. posx = 0
  1251. posy = 40
  1252. info_image = self.font.render(info_string_1,1,(255,255,255))
  1253. s.blit(info_image,(posx,posy))
  1254. elif style == 'Doorway':
  1255. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].move_group == 'solid' and world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].damage == False and world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].civilisation == True and world.maplist[player.pos[2]][player.on_map].npcs[player.pos[1]+ymin][player.pos[0]+xmin] == 0:
  1256. built_here = 1
  1257. price += 2
  1258. else:
  1259. built_here = 0
  1260. if world.maplist[player.pos[2]][player.on_map].npcs[player.pos[1]+ymin][player.pos[0]+xmin] != 0:
  1261. built_here = False
  1262. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].build_here == False:
  1263. if built_here == 1:
  1264. price -= 2
  1265. elif built_here == 2:
  1266. price -= 1
  1267. built_here = 0
  1268. if built_here != 0:
  1269. if built_here == 1:
  1270. s.blit(gra_files.gdic['built'][3],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #door_true here
  1271. elif built_here == 2:
  1272. s.blit(gra_files.gdic['built'][8],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #door_over
  1273. else:
  1274. s.blit(gra_files.gdic['built'][2],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #door_false here
  1275. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1276. # render mode name
  1277. name = '~Built Doorway~'
  1278. name_image = self.font.render(name,1,(255,255,255))
  1279. posx = 0
  1280. posy = 0
  1281. s.blit(name_image,(posx,posy))
  1282. # render wood needed
  1283. wood_need = 0
  1284. wood_string = 'Wood: ' + str(wood_need) + '(' + str(player.inventory.materials.wood) + ')'
  1285. posx = 0
  1286. posy = 15
  1287. if wood_need <= player.inventory.materials.wood:
  1288. wood_image = self.font.render(wood_string,1,(255,255,255))
  1289. else:
  1290. wood_image = self.font.render(wood_string,1,(200,0,0))
  1291. s.blit(wood_image,(posx,posy))
  1292. # render stone needed
  1293. stone_need = 0
  1294. stone_string = 'Stone: ' + str(stone_need) + '(' + str(player.inventory.materials.stone) + ')'
  1295. posx = 160
  1296. posy = 15
  1297. if stone_need <= player.inventory.materials.stone:
  1298. stone_image = self.font.render(stone_string,1,(255,255,255))
  1299. else:
  1300. stone_image = self.font.render(stone_string,1,(200,0,0))
  1301. s.blit(stone_image,(posx,posy))
  1302. # render info line
  1303. info_string_0 = '['+key_name['wasd']+']change Position'
  1304. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']BUILT!'
  1305. posx = 0
  1306. posy = 30
  1307. info_image = self.font.render(info_string_0,1,(255,255,255))
  1308. s.blit(info_image,(posx,posy))
  1309. posx = 0
  1310. posy = 40
  1311. info_image = self.font.render(info_string_1,1,(255,255,255))
  1312. s.blit(info_image,(posx,posy))
  1313. elif style == 'Door':
  1314. 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:
  1315. built_here = 1
  1316. price += 2
  1317. elif world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].civilisation == True:
  1318. built_here = 2
  1319. price += 1
  1320. else:
  1321. built_here = 0
  1322. if world.maplist[player.pos[2]][player.on_map].npcs[player.pos[1]+ymin][player.pos[0]+xmin] != 0:
  1323. built_here = False
  1324. if world.maplist[player.pos[2]][player.on_map].tilemap[player.pos[1]+ymin][player.pos[0]+xmin].build_here == False:
  1325. if built_here == 1:
  1326. price -= 2
  1327. elif built_here == 2:
  1328. price -= 1
  1329. built_here = 0
  1330. if built_here != 0:
  1331. if built_here == 1:
  1332. s.blit(gra_files.gdic['built'][3],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #door_true here
  1333. elif built_here == 2:
  1334. s.blit(gra_files.gdic['built'][8],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #door_over
  1335. else:
  1336. s.blit(gra_files.gdic['built'][2],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #door_false here
  1337. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1338. # render mode name
  1339. name = '~Built Door~'
  1340. name_image = self.font.render(name,1,(255,255,255))
  1341. posx = 0
  1342. posy = 0
  1343. s.blit(name_image,(posx,posy))
  1344. # render wood needed
  1345. wood_need = price
  1346. wood_string = 'Wood: ' + str(wood_need) + '(' + str(player.inventory.materials.wood) + ')'
  1347. posx = 0
  1348. posy = 15
  1349. if wood_need <= player.inventory.materials.wood:
  1350. wood_image = self.font.render(wood_string,1,(255,255,255))
  1351. else:
  1352. wood_image = self.font.render(wood_string,1,(200,0,0))
  1353. s.blit(wood_image,(posx,posy))
  1354. # render stone needed
  1355. stone_need = 0
  1356. stone_string = 'Stone: ' + str(stone_need) + '(' + str(player.inventory.materials.stone) + ')'
  1357. posx = 160
  1358. posy = 15
  1359. if stone_need <= player.inventory.materials.stone:
  1360. stone_image = self.font.render(stone_string,1,(255,255,255))
  1361. else:
  1362. stone_image = self.font.render(stone_string,1,(200,0,0))
  1363. s.blit(stone_image,(posx,posy))
  1364. # render info line
  1365. info_string_0 = '['+key_name['wasd']+']change Position'
  1366. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']BUILT!'
  1367. posx = 0
  1368. posy = 30
  1369. info_image = self.font.render(info_string_0,1,(255,255,255))
  1370. s.blit(info_image,(posx,posy))
  1371. posx = 0
  1372. posy = 40
  1373. info_image = self.font.render(info_string_1,1,(255,255,255))
  1374. s.blit(info_image,(posx,posy))
  1375. elif style == 'Stair up':
  1376. if player.pos[2] > 0:
  1377. 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:
  1378. build_here = 0
  1379. else:
  1380. build_here = 1
  1381. if build_here == 0:
  1382. s.blit(gra_files.gdic['built'][10],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #stair up true 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. else:
  1386. s.blit(gra_files.gdic['built'][11],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #stair up false icon here
  1387. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1388. # render mode name
  1389. name = '~Built stair up~'
  1390. name_image = self.font.render(name,1,(255,255,255))
  1391. posx = 0
  1392. posy = 0
  1393. s.blit(name_image,(posx,posy))
  1394. # render wood needed
  1395. wood_need = 10
  1396. wood_string = 'Wood: ' + str(wood_need) + '(' + str(player.inventory.materials.wood) + ')'
  1397. posx = 0
  1398. posy = 15
  1399. if wood_need <= player.inventory.materials.wood:
  1400. wood_image = self.font.render(wood_string,1,(255,255,255))
  1401. else:
  1402. wood_image = self.font.render(wood_string,1,(200,0,0))
  1403. s.blit(wood_image,(posx,posy))
  1404. # render stone needed
  1405. stone_need = 40
  1406. stone_string = 'Stone: ' + str(stone_need) + '(' + str(player.inventory.materials.stone) + ')'
  1407. posx = 160
  1408. posy = 15
  1409. if stone_need <= player.inventory.materials.stone:
  1410. stone_image = self.font.render(stone_string,1,(255,255,255))
  1411. else:
  1412. stone_image = self.font.render(stone_string,1,(200,0,0))
  1413. s.blit(stone_image,(posx,posy))
  1414. # render info line
  1415. info_string_0 = '['+key_name['wasd']+']change Position'
  1416. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']BUILT!'
  1417. posx = 0
  1418. posy = 30
  1419. info_image = self.font.render(info_string_0,1,(255,255,255))
  1420. s.blit(info_image,(posx,posy))
  1421. posx = 0
  1422. posy = 40
  1423. info_image = self.font.render(info_string_1,1,(255,255,255))
  1424. s.blit(info_image,(posx,posy))
  1425. elif style == 'Stair down':
  1426. if player.pos[2] < 15:
  1427. 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:
  1428. build_here = 0
  1429. else:
  1430. build_here = 1
  1431. if build_here == 0:
  1432. s.blit(gra_files.gdic['built'][12],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #stair up true icon here
  1433. else:
  1434. s.blit(gra_files.gdic['built'][13],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #stair up false icon here
  1435. else:
  1436. s.blit(gra_files.gdic['built'][12],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #stair up false icon here
  1437. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1438. # render mode name
  1439. name = '~Built stair down~'
  1440. name_image = self.font.render(name,1,(255,255,255))
  1441. posx = 0
  1442. posy = 0
  1443. s.blit(name_image,(posx,posy))
  1444. # render wood needed
  1445. wood_need = 10
  1446. wood_string = 'Wood: ' + str(wood_need) + '(' + str(player.inventory.materials.wood) + ')'
  1447. posx = 0
  1448. posy = 15
  1449. if wood_need <= player.inventory.materials.wood:
  1450. wood_image = self.font.render(wood_string,1,(255,255,255))
  1451. else:
  1452. wood_image = self.font.render(wood_string,1,(200,0,0))
  1453. s.blit(wood_image,(posx,posy))
  1454. # render stone needed
  1455. if player.pos[2] > 0:
  1456. stone_need = 40
  1457. else:
  1458. stone_need = 15
  1459. stone_string = 'Stone: ' + str(stone_need) + '(' + str(player.inventory.materials.stone) + ')'
  1460. posx = 160
  1461. posy = 15
  1462. if stone_need <= player.inventory.materials.stone:
  1463. stone_image = self.font.render(stone_string,1,(255,255,255))
  1464. else:
  1465. stone_image = self.font.render(stone_string,1,(200,0,0))
  1466. s.blit(stone_image,(posx,posy))
  1467. # render info line
  1468. info_string_0 = '['+key_name['wasd']+']change Position'
  1469. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']BUILT!'
  1470. posx = 0
  1471. posy = 30
  1472. info_image = self.font.render(info_string_0,1,(255,255,255))
  1473. s.blit(info_image,(posx,posy))
  1474. posx = 0
  1475. posy = 40
  1476. info_image = self.font.render(info_string_1,1,(255,255,255))
  1477. s.blit(info_image,(posx,posy))
  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.seeds:
  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']+']change Size'
  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. shape = world.maplist[player.pos[2]][player.on_map].float_building_shape(player.pos[0]+xmin,player.pos[1]+ymin)
  1536. for y in range(player.pos[1]-8,player.pos[1]+8):
  1537. for x in range(player.pos[0]-6,player.pos[0]+6):
  1538. rx = x-player.pos[0]
  1539. ry = y-player.pos[1]
  1540. if shape[y][x] == 1:
  1541. s.blit(gra_files.gdic['built'][9],(start_pos_x+(rx*32),start_pos_y+(ry*32))) #remove icon here
  1542. s.blit(gra_files.gdic['built'][19],(start_pos_x+(xmin*32),start_pos_y+(ymin*32))) #remove icon here
  1543. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1544. # render mode name
  1545. name = '~Remove~'
  1546. name_image = self.font.render(name,1,(255,255,255))
  1547. posx = 0
  1548. posy = 0
  1549. s.blit(name_image,(posx,posy))
  1550. # render ---
  1551. wood_string = '---'
  1552. posx = 120
  1553. posy = 15
  1554. wood_image = self.font.render(wood_string,1,(255,255,255))
  1555. s.blit(wood_image,(posx,posy))
  1556. # render info line
  1557. info_string_0 = '['+key_name['wasd']+']change Size'
  1558. info_string_1 = '['+key_name['x']+']Leave ['+key_name['e']+']REMOVE!'
  1559. posx = 0
  1560. posy = 30
  1561. info_image = self.font.render(info_string_0,1,(255,255,255))
  1562. s.blit(info_image,(posx,posy))
  1563. posx = 0
  1564. posy = 40
  1565. info_image = self.font.render(info_string_1,1,(255,255,255))
  1566. s.blit(info_image,(posx,posy))
  1567. wood_need = 0
  1568. stone_need = 0
  1569. if game_options.mousepad == 0:
  1570. s_help = pygame.Surface((640,360))
  1571. s_help.fill((255,0,255))
  1572. s_help.blit(s,(80,0))
  1573. s = s_help
  1574. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  1575. s = s.convert_alpha()
  1576. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1577. bg.blit(s,(0,0))
  1578. self.screen.blit(bg,(0,0))
  1579. pygame.display.flip()
  1580. return (wood_need,stone_need)
  1581. def render_place(self,tile,use_name):
  1582. global player
  1583. x = player.pos[0]
  1584. y = player.pos[1]
  1585. start_pos_x = 256 #the center of the main map view
  1586. start_pos_y = 192
  1587. run = True
  1588. while run:
  1589. lootable = False
  1590. placeable = True
  1591. plantable = False
  1592. #1: check if lootable
  1593. for i in range(9,14):
  1594. if tile.techID == tl.tlist['functional'][i].techID:#this is a workbench
  1595. lootable = True
  1596. if tile.use_group == 'gather':
  1597. lootable = True
  1598. #2: check if placeable
  1599. if world.maplist[player.pos[2]][player.on_map].tilemap[y][x].move_group != 'soil' and world.maplist[player.pos[2]][player.on_map].tilemap[y][x].move_group != 'dry_entrance':
  1600. placeable = False
  1601. if world.maplist[player.pos[2]][player.on_map].tilemap[y][x].replace != None:
  1602. placeable = False
  1603. if world.maplist[player.pos[2]][player.on_map].npcs[y][x] != 0:
  1604. placeable = False
  1605. if tile.move_group != 'soil':
  1606. if x == player.pos[0] and y == player.pos[1]:
  1607. placeable = False
  1608. if use_name == 'place(indoor)':
  1609. if world.maplist[player.pos[2]][player.on_map].tilemap[y][x].indoor == False:
  1610. placeable = False
  1611. if use_name == 'place(outdoor)':
  1612. if world.maplist[player.pos[2]][player.on_map].tilemap[y][x].indoor == True:
  1613. placeable = False
  1614. #2.5: check if plantable
  1615. if world.maplist[player.pos[2]][player.on_map].tilemap[y][x].can_grown == True:
  1616. plantable = True
  1617. if use_name != 'plant':
  1618. plantable = True #if the object to be placeced no plant plantable is always true
  1619. #3: render
  1620. self.render(0,True)
  1621. s = pygame.Surface((640,360))
  1622. s.fill((255,0,255))
  1623. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1624. string1 ='~'+tile.name+'~'
  1625. string1_image = self.font.render(string1,1,(255,255,255))
  1626. s.blit(string1_image,(0,0))
  1627. if lootable == False:
  1628. warning = self.font.render('Can\'t be moved later!',1,(200,0,0))
  1629. s.blit(warning,(0,20))
  1630. string2 = '['+key_name['wasd']+']Move ['+key_name['e']+']Place! ['+key_name['x']+']Leave'
  1631. string2_image = self.font.render(string2,1,(255,255,255))
  1632. s.blit(string2_image,(0,40))
  1633. xx = x - player.pos[0]
  1634. yy = y - player.pos[1]
  1635. if placeable == True and plantable == True:
  1636. s.blit(gra_files.gdic['built'][18],(start_pos_x+(xx*32),start_pos_y+(yy*32)))
  1637. else:
  1638. s.blit(gra_files.gdic['built'][17],(start_pos_x+(xx*32),start_pos_y+(yy*32)))
  1639. if game_options.mousepad == 0:
  1640. s_help = pygame.Surface((640,360))
  1641. s_help.fill((255,0,255))
  1642. s_help.blit(s,(80,0))
  1643. s = s_help
  1644. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  1645. s = s.convert_alpha()
  1646. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1647. self.screen.blit(s,(0,0))
  1648. pygame.display.flip()
  1649. #4: user input
  1650. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  1651. if ui == 'exit':
  1652. global master_loop
  1653. global playing
  1654. global exitgame
  1655. exitgame = True
  1656. try:
  1657. save_options(game_options,options_path,os.sep)
  1658. screen.render_load(5)
  1659. save(world,player,time,gods,save_path,os.sep)
  1660. screen.save_tmp_png()
  1661. del player
  1662. except:
  1663. None
  1664. master_loop = False
  1665. playing = False
  1666. run = False
  1667. return('exit')
  1668. if ui == 'w':
  1669. if y > 0 and y > player.pos[1]-2:
  1670. y -= 1
  1671. elif ui == 's':
  1672. if y < max_map_size-1 and y < player.pos[1]+2:
  1673. y += 1
  1674. elif ui == 'a':
  1675. if x > 0 and x > player.pos[0]-2:
  1676. x -= 1
  1677. elif ui == 'd':
  1678. if x < max_map_size-1 and x < player.pos[0]+2:
  1679. x += 1
  1680. elif ui == 'e':
  1681. if placeable == True and plantable == True:
  1682. replace = world.maplist[player.pos[2]][player.on_map].tilemap[y][x]
  1683. world.maplist[player.pos[2]][player.on_map].tilemap[y][x] = deepcopy(tile)
  1684. world.maplist[player.pos[2]][player.on_map].tilemap[y][x].replace = deepcopy(replace)
  1685. world.maplist[player.pos[2]][player.on_map].tilemap[y][x].civilisation = True
  1686. if world.maplist[player.pos[2]][player.on_map].tilemap[y][x].techID == tl.tlist['misc'][0].techID or world.maplist[player.pos[2]][player.on_map].tilemap[y][x].techID == tl.tlist['global_caves'][4].techID:
  1687. world.maplist[player.pos[2]][player.on_map].tilemap[y][x].replace = None
  1688. world.maplist[player.pos[2]][player.on_map].tilemap[y][x].civilisation = False
  1689. if use_name == 'plant':
  1690. mes = 'You planted a '+tile.name+'.'
  1691. else:
  1692. mes = 'You placed a '+tile.name+'.'
  1693. message.add(mes)
  1694. return(x,y)
  1695. elif ui == 'x':
  1696. run = False
  1697. return False
  1698. return False#only to be sure
  1699. def render_textbox_open(self):
  1700. clock = pygame.time.Clock()
  1701. for i in range(-64,1,6):
  1702. s = pygame.Surface((320,240))
  1703. s.fill((255,0,255))
  1704. s.blit(gra_files.gdic['display'][5],(0,i)) #render gui_transparent over gui
  1705. if game_options.mousepad == 0:
  1706. s_help = pygame.Surface((640,360))
  1707. s_help.fill((255,0,255))
  1708. s_help.blit(s,(80,0))
  1709. s = s_help
  1710. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  1711. s = s.convert_alpha()
  1712. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1713. self.screen.blit(s,(0,0))
  1714. pygame.display.flip()
  1715. clock.tick(256)
  1716. def render_request(self,line1,line2,line3,first_call=True):
  1717. #this function just renders 3 lines of text in the textbox
  1718. self.render(0, True)
  1719. if first_call == True:
  1720. self.render_textbox_open()
  1721. s = pygame.Surface((640,380))
  1722. s.fill((255,0,255))
  1723. s.blit(gra_files.gdic['display'][5],(0,0)) #render gui_transparent over gui
  1724. # render lines
  1725. line1_image = self.font.render(line1,1,(255,255,255))
  1726. posx = 0
  1727. posy = 0
  1728. s.blit(line1_image,(posx,posy))
  1729. line2_image = self.font.render(line2,1,(255,255,255))
  1730. posx = 0
  1731. posy = 20
  1732. s.blit(line2_image,(posx,posy))
  1733. line3_image = self.font.render(line3,1,(255,255,255))
  1734. posx = 0
  1735. posy = 40
  1736. s.blit(line3_image,(posx,posy))
  1737. if game_options.mousepad == 0:
  1738. s_help = pygame.Surface((640,360))
  1739. s_help.fill((255,0,255))
  1740. s_help.blit(s,(80,0))
  1741. s = s_help
  1742. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  1743. s = s.convert_alpha()
  1744. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1745. self.screen.blit(s,(0,0))
  1746. pygame.display.flip()
  1747. def render_map(self,level=0):
  1748. run = True
  1749. while run:
  1750. m = pygame.Surface((max_map_size,max_map_size))
  1751. for y in range(0,max_map_size):
  1752. for x in range(0,max_map_size):
  1753. try:
  1754. t_col = world.maplist[level][player.on_map].tilemap[y][x].tile_color
  1755. except:
  1756. level = 0
  1757. t_col = world.maplist[level][player.on_map].tilemap[y][x].tile_color
  1758. 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
  1759. m.blit(gra_files.gdic['tile1']['white'],(x,y))
  1760. else:
  1761. if world.maplist[level][player.on_map].known[y][x] == 1:
  1762. m.blit(gra_files.gdic['tile1'][t_col],(x,y))
  1763. elif world.maplist[level][player.on_map].known[y][x] == 0:
  1764. m.blit(gra_files.gdic['tile1']['black'],(x,y))
  1765. else:
  1766. m.blit(gra_files.gdic['tile1']['black'],(x,y))
  1767. m = pygame.transform.scale(m,(270,270))
  1768. s = pygame.Surface((640,360))
  1769. bg = pygame.Surface((480,360))
  1770. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  1771. s.blit(bg,(0,0))
  1772. if game_options.mousepad == 1:
  1773. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  1774. else:
  1775. s_help = pygame.Surface((160,360))
  1776. s_help.fill((48,48,48))
  1777. s.blit(s_help,(480,0))
  1778. text = '~Map~ [Press['+key_name['x']+'] to leave'
  1779. text_image = screen.font.render(text,1,(255,255,255))
  1780. s.blit(text_image,(5,2))#menue title
  1781. lvl_string = 'Level ' + str(level)
  1782. text_image = screen.font.render(lvl_string,1,(0,0,0))
  1783. if low_res == False:
  1784. s.blit(text_image,(300,70))
  1785. else:
  1786. s.blit(text_image,(190,50))
  1787. s.blit(m,(25,55))
  1788. if game_options.mousepad == 0:
  1789. s_help = pygame.Surface((640,360))
  1790. s_help.fill((48,48,48))
  1791. s_help.blit(s,(80,0))
  1792. s = s_help
  1793. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1794. self.screen.blit(s,(0,0))
  1795. pygame.display.flip()
  1796. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  1797. if ui == 'exit':
  1798. global master_loop
  1799. global playing
  1800. global exitgame
  1801. exitgame = True
  1802. screen.render_load(5)
  1803. save(world,player,time,gods,save_path,os.sep)
  1804. screen.save_tmp_png()
  1805. master_loop = False
  1806. playing = False
  1807. run = False
  1808. return('exit')
  1809. if ui == 'x':
  1810. run = False
  1811. def render_credits(self):
  1812. global master_loop
  1813. run = True
  1814. while run:
  1815. s = pygame.Surface((640,360))
  1816. bg = pygame.Surface((480,360))
  1817. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  1818. s.blit(bg,(0,0))
  1819. if game_options.mousepad == 1 and low_res == False:
  1820. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  1821. else:
  1822. s_help = pygame.Surface((160,360))
  1823. s_help.fill((48,48,48))
  1824. s.blit(s_help,(480,0))
  1825. text = '~Credits~ [Press ['+key_name['x']+'] to leave]'
  1826. text_image = screen.font.render(text,1,(255,255,255))
  1827. s.blit(text_image,(5,2))#menue title
  1828. 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')
  1829. for i in range (0,len(credit_items)):
  1830. text_image = screen.font.render(credit_items[i],1,(0,0,0))
  1831. s.blit(text_image,(21,120+i*25))#blit credit_items
  1832. if game_options.mousepad == 0:
  1833. s_help = pygame.Surface((640,360))
  1834. s_help.fill((48,48,48))
  1835. s_help.blit(s,(80,0))
  1836. s = s_help
  1837. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1838. self.screen.blit(s,(0,0))
  1839. pygame.display.flip()
  1840. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  1841. if ui == 'exit':
  1842. master_loop = False
  1843. run = False
  1844. return('exit')
  1845. if ui == 'x':
  1846. run = False
  1847. def render_status(self):
  1848. player_attribute = ('Strength: '+str(player.attribute.p_strength),
  1849. 'Skill: '+str(player.attribute.p_defense),
  1850. 'Power: '+str(player.attribute.m_strength),
  1851. 'Will: '+str(player.attribute.m_defense),
  1852. 'Health: '+str(player.lp)+'/'+str(player.attribute.max_lp),
  1853. '--> SKILLS')
  1854. attribute_info = ('Strength','Skill','Power','Will','Health')
  1855. if player.skill.woodcutting == 'Novice':
  1856. woodcutting_next_lvl = '200'
  1857. else:
  1858. woodcutting_next_lvl = '1000'
  1859. if player.skill.mining == 'Novice':
  1860. mining_next_lvl = '200'
  1861. else:
  1862. mining_next_lvl = '1000'
  1863. player_skills = ('Weapon Crafting: '+player.skill.weapon_crafting,
  1864. 'Metallurgy: '+player.skill.metallurgy,
  1865. 'Alchemy: '+player.skill.alchemy,
  1866. 'Woodcutting: '+player.skill.woodcutting+' ('+str(player.skill.woodcutting_progress)+'/'+woodcutting_next_lvl+')',
  1867. 'Mining: '+player.skill.mining+' ('+str(player.skill.mining_progress)+'/'+mining_next_lvl+')',
  1868. '<-- ATTRIBUTE')
  1869. skill_info = ('Weapon Crafting','Metallurgy','Alchemy','Woodcutting','Mining')
  1870. run = True
  1871. while run:
  1872. c = screen.get_choice('Attributes',player_attribute,True)
  1873. if c == 'Break':
  1874. run = False
  1875. return False
  1876. if c < 5:
  1877. screen.render_text(texts[attribute_info[c]])
  1878. elif c == 5:
  1879. run2 = True
  1880. while run2:
  1881. d = screen.get_choice('Skills',player_skills,True)
  1882. if d == 'Break':
  1883. run = False
  1884. run2 = False
  1885. return False
  1886. if d < 5:
  1887. screen.render_text(texts[skill_info[d]])
  1888. elif d == 5:
  1889. run2 = False
  1890. def render_text(self,text,replace_keys=True,more_txt=False,simulation= False):
  1891. run = True
  1892. while run:
  1893. if low_res == False:
  1894. s = pygame.Surface((640,360))
  1895. else:
  1896. s = pygame.Surface((320,240))
  1897. bg = pygame.Surface((480,360))
  1898. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  1899. if low_res == True:
  1900. bg = pygame.transform.scale(bg,(320,240))
  1901. s.blit(bg,(0,0))
  1902. if game_options.mousepad == 1 and low_res == False:
  1903. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  1904. else:
  1905. s_help = pygame.Surface((160,360))
  1906. s_help.fill((48,48,48))
  1907. s.blit(s_help,(480,0))
  1908. if simulation == False:
  1909. if more_txt == False:
  1910. top_text = '[Press ['+key_name['x']+'] to leave]'
  1911. else:
  1912. top_text = '[Press ['+key_name['e']+'] for next page]'
  1913. text_image = screen.font.render(top_text,1,(255,255,255))
  1914. s.blit(text_image,(5,2))#menue title
  1915. for i in range (0,len(text)):
  1916. text_image = screen.font.render(text[i],1,(0,0,0))
  1917. if low_res == False:
  1918. s.blit(text_image,(60,80+i*25))#blit credit_items
  1919. else:
  1920. s.blit(text_image,(21,36+i*20))#blit credit_items
  1921. if simulation == True:
  1922. return s
  1923. if game_options.mousepad == 0 and low_res == False:
  1924. s_help = pygame.Surface((640,360))
  1925. s_help.fill((48,48,48))
  1926. s_help.blit(s,(80,0))
  1927. s = s_help
  1928. if low_res == False:
  1929. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1930. self.screen.blit(s,(0,0))
  1931. pygame.display.flip()
  1932. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  1933. if ui == 'exit':
  1934. global master_loop
  1935. global playing
  1936. global exitgame
  1937. exitgame = True
  1938. try:
  1939. screen.render_load(5)
  1940. save(world,player,time,gods,save_path,os.sep)
  1941. screen.save_tmp_png()
  1942. del player
  1943. except:
  1944. None
  1945. master_loop = False
  1946. playing = False
  1947. run = False
  1948. return('exit')
  1949. if ui == 'x':
  1950. run = False
  1951. elif ui == 'e' and more_txt == True:
  1952. run = False
  1953. def render_multi_text(self,texts):
  1954. run = True
  1955. page = 0
  1956. total_pages = len(texts)
  1957. while run:
  1958. s = self.render_text(texts[page],simulation=True)
  1959. page_txt = 'Page '+str(page+1)+ ' of '+str(total_pages)+' ['+key_name['x']+'] - leave'
  1960. page_image = screen.font.render(page_txt,1,(255,255,255))
  1961. s.blit(page_image,(5,2))#menue title
  1962. if game_options.mousepad == 0 and low_res == False:
  1963. s_help = pygame.Surface((640,360))
  1964. s_help.fill((48,48,48))
  1965. s_help.blit(s,(80,0))
  1966. s = s_help
  1967. if low_res == False:
  1968. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  1969. self.screen.blit(s,(0,0))
  1970. pygame.display.flip()
  1971. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  1972. if ui == 's' or ui == 'd':
  1973. page += 1
  1974. if page > total_pages-1:
  1975. page = 0
  1976. elif ui == 'w' or ui == 'a':
  1977. page -= 1
  1978. if page < 0:
  1979. page = total_pages-1
  1980. elif ui == 'x':
  1981. run = False
  1982. def render_options(self):
  1983. run = True
  1984. num = 0
  1985. options_path = save_path
  1986. for c in range(0,5):
  1987. options_path = options_path.replace(os.sep + 'World' + str(c),'')
  1988. while run:
  1989. if game_options.screenmode == 2:
  1990. winm = 'Screenmode: Fullscreen'
  1991. elif game_options.screenmode == 1:
  1992. winm = 'Screenmode: Windowed(1280X720)'
  1993. else:
  1994. winm = 'Screenmode: Windowed(640X360)'
  1995. if game_options.bgmmode == 1:
  1996. audiom = 'BGM: ON'
  1997. else:
  1998. audiom = 'BGM: OFF'
  1999. if game_options.sfxmode == 1:
  2000. sfxm = 'SFX: ON'
  2001. else:
  2002. sfxm = 'SFX: OFF'
  2003. if game_options.turnmode == 1:
  2004. turnm = 'Gamemode: Semi-Realtime'
  2005. else:
  2006. turnm = 'Gamemode: Turnbased'
  2007. if game_options.mousepad == 1:
  2008. mousem = 'Use Mouse: yes'
  2009. else:
  2010. mousem = 'Use Mouse: no'
  2011. if game_options.check_version == 1:
  2012. versm = 'Check Version: yes'
  2013. else:
  2014. versm = 'Check Version: no'
  2015. s = pygame.Surface((640,360))
  2016. bg = pygame.Surface((480,360))
  2017. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  2018. if low_res == True:
  2019. bg = pygame.transform.scale(bg,(320,240))
  2020. s.blit(bg,(0,0))
  2021. text = '~Options~ [Press ['+key_name['e']+'] to choose]'
  2022. text_image = screen.font.render(text,1,(255,255,255))
  2023. s.blit(text_image,(5,2))#menue title
  2024. menu_items = (winm,audiom,sfxm,turnm,mousem,versm,'Done')
  2025. for i in range (0,len(menu_items)):
  2026. text_image = screen.font.render(menu_items[i],1,(0,0,0))
  2027. s.blit(text_image,(21,120+i*25))#blit menu_items
  2028. s.blit(gra_files.gdic['display'][4],(0,112+num*25))#blit marker
  2029. if game_options.mousepad == 1:
  2030. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2031. else:
  2032. s_help = pygame.Surface((160,360))
  2033. s_help.fill((48,48,48))
  2034. s.blit(s_help,(480,0))
  2035. if game_options.mousepad == 0:
  2036. s_help = pygame.Surface((640,360))
  2037. s_help.fill((48,48,48))
  2038. s_help.blit(s,(80,0))
  2039. s = s_help
  2040. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  2041. self.screen.blit(s,(0,0))
  2042. pygame.display.flip()
  2043. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2044. if ui == 'exit':
  2045. global master_loop
  2046. global playing
  2047. global exitgame
  2048. global player
  2049. exitgame = True
  2050. try:
  2051. save_options(game_options,options_path,os.sep)
  2052. screen.render_load(5)
  2053. save(world,player,time,gods,save_path,os.sep)
  2054. screen.save_tmp_png()
  2055. del player
  2056. except:
  2057. None
  2058. master_loop = False
  2059. playing = False
  2060. run = False
  2061. return('exit')
  2062. if ui == 'w':
  2063. num -= 1
  2064. if num < 0:
  2065. num = len(menu_items)-1
  2066. if ui == 's':
  2067. num += 1
  2068. if num >= len(menu_items):
  2069. num = 0
  2070. if ui == 'x':
  2071. run = False
  2072. if ui == 'e':
  2073. if num == 0:
  2074. screen.re_init()
  2075. pygame.display.flip()
  2076. save_options(game_options,options_path,os.sep)
  2077. if num == 1:
  2078. if game_options.bgmmode == 1:
  2079. game_options.bgmmode = 0
  2080. pygame.mixer.music.pause()
  2081. else:
  2082. game_options.bgmmode = 1
  2083. pygame.mixer.music.unpause()
  2084. bgm.check_for_song(force_play=True)
  2085. save_options(game_options,options_path,os.sep)
  2086. if num == 2:
  2087. if game_options.sfxmode == 1:
  2088. game_options.sfxmode = 0
  2089. else:
  2090. game_options.sfxmode = 1
  2091. save_options(game_options,options_path,os.sep)
  2092. if num == 3:
  2093. if game_options.turnmode == 1:
  2094. game_options.turnmode = 0
  2095. else:
  2096. game_options.turnmode = 1
  2097. save_options(game_options,options_path,os.sep)
  2098. if num == 4 and low_res == False:
  2099. if game_options.mousepad == 1:
  2100. game_options.mousepad = 0
  2101. else:
  2102. game_options.mousepad = 1
  2103. pygame.mouse.set_visible(game_options.mousepad)
  2104. save_options(game_options,options_path,os.sep)
  2105. if num == 5:
  2106. if game_options.check_version == 1:
  2107. game_options.check_version = 0
  2108. else:
  2109. game_options.check_version = 1
  2110. save_options(game_options,options_path,os.sep)
  2111. if num == 6:
  2112. save_options(game_options,options_path,os.sep)
  2113. run = False
  2114. def render_brake(self,simulate= False):
  2115. run = True
  2116. num = 0
  2117. global exitgame
  2118. global playing
  2119. global player
  2120. while run:
  2121. if low_res == False:
  2122. s = pygame.Surface((640,360))
  2123. else:
  2124. s = pygame.Surface((320,240))
  2125. bg = pygame.Surface((480,360))
  2126. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  2127. if low_res == True:
  2128. bg = pygame.transform.scale(bg,(320,240))
  2129. s.blit(bg,(0,0))
  2130. text = '~Game Paused~ [Press ['+key_name['e']+'] to choose]'
  2131. text_image = screen.font.render(text,1,(255,255,255))
  2132. s.blit(text_image,(5,2))#menue title
  2133. menu_items = ('Resume','Status','Message History','Save and Exit', 'Options',)
  2134. for i in range (0,len(menu_items)):
  2135. text_image = screen.font.render(menu_items[i],1,(0,0,0))
  2136. if low_res == False:
  2137. s.blit(text_image,(21,120+i*25))#blit menu_items
  2138. else:
  2139. s.blit(text_image,(21,46+i*25))#blit menu_items
  2140. if low_res == False:
  2141. s.blit(gra_files.gdic['display'][4],(0,112+num*25))#blit marker
  2142. else:
  2143. s.blit(gra_files.gdic['display'][4],(0,38+num*25))#blit marker
  2144. if game_options.mousepad == 1 and low_res != True:
  2145. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2146. else:
  2147. s_help = pygame.Surface((160,360))
  2148. s_help.fill((48,48,48))
  2149. s.blit(s_help,(480,0))
  2150. if game_options.mousepad == 0 and low_res == False:
  2151. s_help = pygame.Surface((640,360))
  2152. s_help.fill((48,48,48))
  2153. s_help.blit(s,(80,0))
  2154. s = s_help
  2155. if low_res == False:
  2156. s = pygame.transform.scale(s,(self.displayx,self.displayy))
  2157. if simulate == True:
  2158. return s
  2159. self.screen.blit(s,(0,0))
  2160. pygame.display.flip()
  2161. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2162. if ui == 'exit':
  2163. global master_loop
  2164. global playing
  2165. global exitgame
  2166. exitgame = True
  2167. screen.render_load(5)
  2168. save(world,player,time,gods,save_path,os.sep)
  2169. screen.save_tmp_png()
  2170. master_loop = False
  2171. playing = False
  2172. run = False
  2173. return('exit')
  2174. if ui == 'w':
  2175. num -= 1
  2176. if num < 0:
  2177. num = len(menu_items)-1
  2178. if ui == 's':
  2179. num += 1
  2180. if num >= len(menu_items):
  2181. num = 0
  2182. if ui == 'x':
  2183. run = False
  2184. screen.render_fade(True,False,'screen')
  2185. if ui == 'e':
  2186. if num == 0:
  2187. run = False
  2188. screen.render_fade(True,False,'screen')
  2189. if num == 1:
  2190. screen.render_status()
  2191. if num == 2:
  2192. do = message.render_history()
  2193. if do == 'exit':
  2194. run = False
  2195. if num == 3:
  2196. exitgame = True
  2197. screen.render_load(5)
  2198. save(world,player,time,gods,save_path,os.sep)
  2199. screen.save_tmp_png()
  2200. del player
  2201. playing = False
  2202. run = False
  2203. if num == 4:
  2204. do = screen.render_options()
  2205. if do == 'exit':
  2206. run = False
  2207. return exitgame
  2208. def get_choice(self,headline,choices,allow_chancel,style='Default'):
  2209. #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
  2210. run = True
  2211. num = 0
  2212. while run:
  2213. s = pygame.Surface((640,360))
  2214. bg = pygame.Surface((480,360))
  2215. if style == 'Default':
  2216. bg.blit(gra_files.gdic['display'][1],(0,0)) #render background
  2217. elif style == 'Warning':
  2218. bg.blit(gra_files.gdic['display'][17],(0,0))
  2219. s.blit(bg,(0,0))
  2220. text_image = screen.font.render(headline,1,(255,255,255))
  2221. if low_res == False:
  2222. s.blit(text_image,(5,2))#menue title
  2223. else:
  2224. s.blit(text_image,(0,2))#menue title
  2225. menu_items = choices
  2226. for i in range (0,len(menu_items)):
  2227. text_image = screen.font.render(menu_items[i],1,(0,0,0))
  2228. if low_res == False:
  2229. s.blit(text_image,(21,120+i*25))#blit menu_items
  2230. else:
  2231. s.blit(text_image,(21,46+i*25))#blit menu_items
  2232. if allow_chancel == True:
  2233. string = '['+key_name['e']+'] - choose ['+key_name['x']+'] - leave'
  2234. text_image = screen.font.render(string,1,(255,255,255))
  2235. if low_res == True:
  2236. s.blit(text_image,(0,225))
  2237. else:
  2238. s.blit(text_image,(5,335))
  2239. else:
  2240. string = '['+key_name['e']+'] - choose'
  2241. text_image = screen.font.render(string,1,(255,255,255))
  2242. if low_res == True:
  2243. s.blit(text_image,(0,225))
  2244. else:
  2245. s.blit(text_image,(5,335))
  2246. if style == 'Default':
  2247. if low_res == False:
  2248. s.blit(gra_files.gdic['display'][4],(0,112+num*25))#blit marker
  2249. else:
  2250. s.blit(gra_files.gdic['display'][4],(0,38+num*25))#blit marker
  2251. elif style == 'Warning':
  2252. if low_res == False:
  2253. s.blit(gra_files.gdic['display'][18],(0,112+num*25))#blit marker
  2254. else:
  2255. s.blit(gra_files.gdic['display'][18],(0,38+num*25))#blit marker
  2256. if game_options.mousepad == 1:
  2257. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2258. else:
  2259. s_help = pygame.Surface((160,360))
  2260. s_help.fill((48,48,48))
  2261. s.blit(s_help,(480,0))
  2262. if game_options.mousepad == 0:
  2263. s_help = pygame.Surface((640,360))
  2264. s_help.fill((48,48,48))
  2265. s_help.blit(s,(80,0))
  2266. s = s_help
  2267. else:
  2268. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2269. s = pygame.transform.scale(s,(screen.displayx,screen.displayy))
  2270. screen.screen.blit(s,(0,0))
  2271. pygame.display.flip()
  2272. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2273. if ui == 'exit':
  2274. global master_loop
  2275. global playing
  2276. global exitgame
  2277. global player
  2278. exitgame = True
  2279. try:
  2280. screen.render_load(5)
  2281. save(world,player,time,gods,save_path,os.sep)
  2282. screen.save_tmp_png()
  2283. except:
  2284. None
  2285. master_loop = False
  2286. playing = False
  2287. run = False
  2288. return('exit')
  2289. if ui == 'w':
  2290. num -= 1
  2291. if num < 0:
  2292. num = len(menu_items)-1
  2293. if ui == 's':
  2294. num += 1
  2295. if num >= len(menu_items):
  2296. num = 0
  2297. if ui == 'e':
  2298. run = False
  2299. return num
  2300. if ui == 'x' and allow_chancel == True:
  2301. run = False
  2302. return 'Break'
  2303. def string_input(self, input_message, length):
  2304. run = True
  2305. string = ''
  2306. pos = 0
  2307. x = 0
  2308. y = 0
  2309. 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', '.',','),('(','[','<','{',')',']','>','}','#','+','-','_','*','/','&','%'))
  2310. while run:
  2311. s = pygame.Surface((640,360))
  2312. s.blit(gra_files.gdic['display'][1],(0,0)) #render background
  2313. text_image = screen.font.render(input_message,1,(255,255,255))
  2314. s.blit(text_image,(5,2))#menue title
  2315. num_stars = length - len(string)
  2316. star_string = ''
  2317. if num_stars > 0:
  2318. for i in range (0,num_stars):
  2319. star_string += '*'
  2320. shown_string = string + '_' + star_string
  2321. string_image = screen.font.render(shown_string,1,(255,255,255))
  2322. s.blit(string_image,(5,35))#string so far
  2323. for i in range (0,5):#blit chars
  2324. for j in range (0,len(char_field[1])):
  2325. if i == y and j == x:
  2326. char_image = screen.font.render(char_field[i][j],1,(255,255,255))
  2327. else:
  2328. char_image = screen.font.render(char_field[i][j],1,(0,0,0))
  2329. if low_res == False:
  2330. s.blit(char_image,(55+(j*20),150+(i*20)))
  2331. else:
  2332. s.blit(char_image,(5+(j*20),90+(i*20)))
  2333. if game_options.mousepad == 1 and low_res == False:
  2334. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2335. else:
  2336. s_help = pygame.Surface((160,360))
  2337. s_help.fill((48,48,48))
  2338. s.blit(s_help,(480,0))
  2339. text = '['+key_name['e']+'] - Add Char ['+key_name['x']+'] - Del Char ['+key_name['b']+'] - Done'
  2340. text_image = screen.font.render(text,1,(255,255,255))
  2341. if low_res == False:
  2342. s.blit(text_image,(5,335))
  2343. else:
  2344. help_sur = pygame.Surface((320,16))
  2345. help_sur.fill((48,48,48))
  2346. help_sur.blit(text_image,(5,5))
  2347. s.blit(help_sur,(0,224))
  2348. if game_options.mousepad == 0 and low_res == False:
  2349. s_help = pygame.Surface((640,360))
  2350. s_help.fill((48,48,48))
  2351. s_help.blit(s,(80,0))
  2352. s = s_help
  2353. if low_res == False:
  2354. s = pygame.transform.scale(s,(screen.displayx,screen.displayy))
  2355. screen.screen.blit(s,(0,0))
  2356. pygame.display.flip()
  2357. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2358. if ui == 'w':
  2359. y -= 1
  2360. if y < 0:
  2361. y = 4
  2362. if ui == 's':
  2363. y += 1
  2364. if y > 4:
  2365. y = 0
  2366. if ui == 'a':
  2367. x -= 1
  2368. if x < 0:
  2369. x = len(char_field[1])-1
  2370. if ui == 'd':
  2371. x += 1
  2372. if x > len(char_field[1])-1:
  2373. x = 0
  2374. if ui == 'e':
  2375. if pos <= length:
  2376. string += char_field[y][x]
  2377. pos += 1
  2378. if ui == 'b':
  2379. run = False
  2380. if ui == 'x':
  2381. if pos > 0:
  2382. pos -= 1
  2383. string = string[:pos]
  2384. return string
  2385. def render_dead(self):
  2386. global exitgame
  2387. self.reset_hit_matrix()
  2388. if player.godmode == True:
  2389. player.respawn()
  2390. message.add('YOU DIE.. NOT!')
  2391. return True
  2392. run = True
  2393. while run:
  2394. if low_res == False:
  2395. s = pygame.Surface((640,360))
  2396. else:
  2397. s = pygame.Surface((320,240))
  2398. s.fill((48,48,48)) #paint it grey(to clear the screen)
  2399. text_image = screen.font.render('YOU ARE DEAD!',1,(255,255,255))
  2400. if low_res == False:
  2401. s.blit(text_image,(175,60))
  2402. else:
  2403. s.blit(text_image,(75,60))
  2404. if player.difficulty == 3: #you play on roguelike mode
  2405. choose_string = '------------- ['+key_name['x']+'] - END GAME'
  2406. else:#you play on a other mode
  2407. choose_string = '['+key_name['e']+'] - RESPAWN ['+key_name['x']+'] - END GAME'
  2408. choose_image = screen.font.render(choose_string,1,(255,255,255))
  2409. if low_res == False:
  2410. s.blit(choose_image,(125,200))
  2411. else:
  2412. s.blit(choose_image,(25,200))
  2413. if game_options.mousepad == 1 and low_res == False:
  2414. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2415. else:
  2416. s_help = pygame.Surface((160,360))
  2417. s_help.fill((48,48,48))
  2418. s.blit(s_help,(480,0))
  2419. if game_options.mousepad == 0 and low_res == False:
  2420. s_help = pygame.Surface((640,360))
  2421. s_help.fill((48,48,48))
  2422. s_help.blit(s,(80,0))
  2423. s = s_help
  2424. else:
  2425. s.blit(gra_files.gdic['display'][8],(480,0)) #render mouse pad
  2426. if low_res == False:
  2427. s = pygame.transform.scale(s,(screen.displayx,screen.displayy))
  2428. screen.screen.blit(s,(0,0))
  2429. pygame.display.flip()
  2430. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  2431. if ui == 'exit':
  2432. global master_loop
  2433. global playing
  2434. global exitgame
  2435. exitgame = True
  2436. if player.difficulty !=3:
  2437. screen.render_load(5)
  2438. save(world,player,time,gods,save_path,os.sep)
  2439. screen.save_tmp_png()
  2440. else:
  2441. files_to_remove = ('gods.data','player.data','world.data','time.data')
  2442. for i in files_to_remove:
  2443. del_file = save_path + os.sep + i
  2444. try:
  2445. os.remove(del_file)
  2446. except:
  2447. None
  2448. master_loop = False
  2449. playing = False
  2450. run = False
  2451. return('exit')
  2452. if ui == 'e' and player.difficulty != 3:
  2453. player.respawn()
  2454. save(world,player,time,gods,save_path,os.sep)
  2455. run = False
  2456. elif ui == 'x':
  2457. player.respawn()
  2458. if player.difficulty != 3:
  2459. screen.render_load(5)
  2460. save(world,player,time,gods,save_path,os.sep)
  2461. screen.save_tmp_png()
  2462. else:
  2463. files_to_remove = ('gods.data','player.data','world.data','time.data')
  2464. for i in files_to_remove:
  2465. del_file = save_path + os.sep + i
  2466. try:
  2467. os.remove(del_file)
  2468. except:
  2469. None
  2470. run = False
  2471. exitgame = True
  2472. class maP():
  2473. def __init__(self, name, tilemap, visit=False, map_type='overworld',monster_num=1):
  2474. self.name = name
  2475. self.known = []
  2476. self.containers = []
  2477. self.tilemap = tilemap
  2478. self.visit = visit
  2479. self.last_visit = 0 #-------test only
  2480. self.map_type = map_type
  2481. self.monster_num = monster_num
  2482. self.build_type = 'Full' #Full: build everything you want, Part: no stairs, None: Buildmode is not callable
  2483. self.thirst_multi_day = 1
  2484. self.thirst_multi_night = 1
  2485. self.no_monster_respawn = False
  2486. self.countdowns = []
  2487. self.npcs = []
  2488. self.monster_plus = 0
  2489. self.monster_count = 0
  2490. self.music_day_original = 'overworld'
  2491. self.music_day = self.music_day_original
  2492. self.music_night_original = 'night'
  2493. self.music_night = self.music_night_original
  2494. self.generation_release = release_number
  2495. for y in range (0,max_map_size):
  2496. self.known.append([])
  2497. for x in range (0,max_map_size):
  2498. self.known[y].append(0)
  2499. for y in range (0,max_map_size):
  2500. self.containers.append([])
  2501. for x in range (0,max_map_size):
  2502. self.containers[y].append(0)
  2503. for y in range (0,max_map_size):
  2504. self.npcs.append([])
  2505. for x in range (0,max_map_size):
  2506. self.npcs[y].append(0)
  2507. def fill(self, tile):
  2508. for y in range (0,max_map_size):
  2509. for x in range(0,max_map_size):
  2510. self.tilemap[y][x] = deepcopy(tile)
  2511. def check_fov(self,x,y,dist):
  2512. fov = []
  2513. startx = x-8
  2514. starty = y-6
  2515. extreme_coordinates = []
  2516. dist_coordinates = []
  2517. for yy in range(0,12):
  2518. fov.append([])
  2519. for xx in range(0,15):
  2520. fov[yy].append(0)
  2521. dist1 = ((8-xx)**2+(6-yy)**2)**0.5
  2522. if dist1 > 0:
  2523. extreme_coordinates.append((xx,yy))
  2524. dist_coordinates.append(dist1)
  2525. for i in range(0,len(extreme_coordinates)-1):
  2526. c = 0
  2527. run = True
  2528. while run:
  2529. dir_x = (8-extreme_coordinates[i][0])/dist_coordinates[i]
  2530. dir_y = (6-extreme_coordinates[i][1])/dist_coordinates[i]
  2531. lx = int(round(8+c*dir_x))
  2532. ly = int(6+c*dir_y)
  2533. if ly < 6:
  2534. ly += 1
  2535. elif ly > 6:
  2536. ly -= 1
  2537. ldist = ((8-lx)**2+(6-ly)**2)**0.5
  2538. try:
  2539. fov[ly][lx] = 1
  2540. except:
  2541. None
  2542. c+=1
  2543. if lx < 0 or lx > 14 or ly < 0 or ly > 11:
  2544. run = False
  2545. elif ldist >= dist:
  2546. run = False
  2547. elif self.tilemap[starty+ly][startx+lx].transparency == False:
  2548. run = False
  2549. return fov
  2550. def check_los(self,startx,starty,endx,endy):
  2551. 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:
  2552. return False
  2553. try:
  2554. m = (startx-endx)/(starty-endy)
  2555. except:
  2556. m = 'error'
  2557. if m != 'error':
  2558. n = starty-(m*startx)
  2559. if startx < endx:
  2560. c = 1
  2561. elif startx > endx:
  2562. c = -1
  2563. else:
  2564. return True
  2565. else:
  2566. if starty < endy:
  2567. c = 1
  2568. elif starty > endy:
  2569. c = -1
  2570. else:
  2571. return True
  2572. test = True
  2573. run=True
  2574. count = 0
  2575. while run:
  2576. if m != 'error':
  2577. x = startx + count
  2578. y = int((m*x)+n)
  2579. elif starty==endy:
  2580. x = startx
  2581. y = starty + count
  2582. try:
  2583. if self.tilemap[y][x].transparency == False and x != endx and y != endy:
  2584. test = False
  2585. if x == endx or y == endy:
  2586. run = False
  2587. count += c
  2588. except:
  2589. run = False
  2590. return test
  2591. def set_round_frame(self,tile,radius):
  2592. center = int(max_map_size/2)
  2593. for y in range(0,max_map_size):
  2594. for x in range(0,max_map_size):
  2595. range_x = x-center
  2596. range_y = y-center
  2597. if ((range_x**2+range_y**2)**0.5) > radius:
  2598. self.tilemap[y][x] = tile
  2599. def set_music(self,day,night,change_original=False):
  2600. if day != None:
  2601. self.music_day = day
  2602. if change_original == True:
  2603. self.music_day_original = day
  2604. if night != None:
  2605. self.music_night = night
  2606. if change_original == True:
  2607. self.music_night_original = night
  2608. def drunken_finder(self,startx,starty,tile):
  2609. x = startx
  2610. y = starty
  2611. run = True
  2612. while run:
  2613. direction = random.randint(0,3)
  2614. if direction == 0:
  2615. y -= 1
  2616. elif direction == 1:
  2617. x += 1
  2618. elif direction == 2:
  2619. y += 1
  2620. else:
  2621. x -= 1
  2622. if self.tilemap[y][x].techID == tile.techID:
  2623. run = False
  2624. return (x,y)
  2625. def drunken_walker(self,startx,starty,tile_replace,num_replace):
  2626. num = 1
  2627. x = startx
  2628. y = starty
  2629. self.tilemap[y][x] = tile_replace
  2630. while num < num_replace:
  2631. #step 0: get possible directions
  2632. dir_list = []
  2633. for n in range(-1,2):
  2634. if x+n < max_map_size-2 and x+n > 2:
  2635. if x+n < max_map_size-7 and x+n > 7:
  2636. count = 5
  2637. else:
  2638. count = min((max_map_size-2)-(x+n),(x+n),3)
  2639. count = max(count,1)#only to be sure count < 1
  2640. for c in range(0,count):
  2641. dir_list.append([x+n,y])
  2642. if y+n < max_map_size-2 and y+n > 2:
  2643. if y+n < max_map_size-7 and y+n > 7:
  2644. count = 5
  2645. else:
  2646. count = min((max_map_size-2)-(y+n),(y+n),3)
  2647. count = max(count,1)#only to be sure count < 1
  2648. for c in range(0,count):
  2649. dir_list.append([x,y+n])
  2650. #step 1: set tile new tile
  2651. ran = random.randint(0,len(dir_list)-1)
  2652. x = dir_list[ran][0]
  2653. y = dir_list[ran][1]
  2654. if self.tilemap[y][x].techID != tile_replace.techID:
  2655. self.tilemap[y][x] = tile_replace
  2656. num += 1
  2657. def floating(self,startx,starty,tile_fill,tile_border):
  2658. #its important to use a tile_fill that isn't on the map and a tile_border that is on the map
  2659. run = True
  2660. self.tilemap[starty][startx] = deepcopy(tile_fill)
  2661. while run:
  2662. count = 0
  2663. for y in range(0,max_map_size):
  2664. for x in range(0,max_map_size):
  2665. if self.tilemap[y][x].techID == tile_fill.techID:
  2666. for yy in range(y-1,y+2):
  2667. for xx in range(x-1,x+2):
  2668. try:
  2669. if self.tilemap[yy][xx].techID != tile_border.techID and self.tilemap[yy][xx].techID != tile_fill.techID:
  2670. self.tilemap[yy][xx] = deepcopy(tile_fill)
  2671. count += 1
  2672. except:
  2673. None
  2674. if count == 0:
  2675. run = False
  2676. def float_civilisation(self,start_x,start_y):
  2677. tm = []
  2678. for y in range(0,max_map_size):
  2679. tm.append([])
  2680. for x in range(0,max_map_size):
  2681. tm[y].append(0)
  2682. tm[start_y][start_x] = 1
  2683. run = True
  2684. total_count = 1
  2685. while run:
  2686. count = 0
  2687. for yy in range(0,max_map_size):
  2688. for xx in range(0,max_map_size):
  2689. if tm[yy][xx] == 1:
  2690. for yyy in range(yy-1,yy+2):
  2691. for xxx in range(xx-1,xx+2):
  2692. try:
  2693. if tm[yyy][xxx] == 0 and self.tilemap[yyy][xxx].move_group == 'soil' and self.tilemap[yyy][xxx].civilisation == True:
  2694. tm[yyy][xxx] = 1
  2695. count += 1
  2696. total_count += 1
  2697. elif self.tilemap[yyy][xxx].civilisation == False:
  2698. return 0
  2699. except:
  2700. None
  2701. if count == 0:
  2702. run = False
  2703. return total_count
  2704. def float_building_shape(self,start_x,start_y):
  2705. help_map = []
  2706. for i in range(0,max_map_size):
  2707. help_map.append([])
  2708. for j in range(0,max_map_size):
  2709. help_map[i].append(0)
  2710. if self.tilemap[start_y][start_x].civilisation == True:
  2711. help_map[start_y][start_x] = 1
  2712. else:
  2713. return help_map
  2714. run = True
  2715. while run:
  2716. count = 0
  2717. for y in range(0,max_map_size):
  2718. for x in range(0,max_map_size):
  2719. if help_map[y][x] == 1:
  2720. for yy in range(y-1,y+2):
  2721. for xx in range(x-1,x+2):
  2722. if self.tilemap[yy][xx].civilisation == True and help_map[yy][xx] == 0:
  2723. help_map[yy][xx] = 1
  2724. count += 1
  2725. if count == 0:
  2726. run = False
  2727. return help_map
  2728. def get_quarter_size(self,startx,starty):
  2729. #this funktion gives back a tulpel with the width and height of a quarter made out of the same tile like the start position
  2730. techID = self.tilemap[starty][startx].techID
  2731. q_width = 0
  2732. q_height = 0
  2733. run_w = True
  2734. run_h = True
  2735. while run_w:
  2736. if self.tilemap[starty][startx+q_width].techID == techID:
  2737. q_width += 1
  2738. else:
  2739. run_w = False
  2740. while run_h:
  2741. if self.tilemap[starty+q_height][startx].techID == techID:
  2742. q_height += 1
  2743. else:
  2744. run_h = False
  2745. return (q_width,q_height)
  2746. def set_frame(self,tile):
  2747. for y in range (0,max_map_size):
  2748. for x in range (0,max_map_size):
  2749. if x == 0 or x == max_map_size-1 or y == 0 or y == max_map_size-1:
  2750. self.tilemap[y][x] = tile
  2751. def cut(self, minx, maxx, miny, maxy, replace):
  2752. #everything that is not between min and mx is replaced abainst a tile
  2753. for y in range (0,max_map_size):
  2754. for x in range (0,max_map_size):
  2755. if x < minx or x > maxx or y < miny or y > maxy:
  2756. self.tilemap[y][x] = replace
  2757. def imp(self, start_x, start_y, replace_inner, replace_outer, step_min, step_max, circles, replace_except=None): #dig random caves
  2758. #was made to generate random caves but dosn't pleased me. maybe this can be used for mazes.(unused atm)
  2759. x = start_x
  2760. y = start_y
  2761. for l in range (0,circles):
  2762. run = True
  2763. while run:
  2764. direction = random.randint(0,3)
  2765. move_x = 0
  2766. move_y = 0
  2767. if direction == 0:
  2768. move_y = -1
  2769. elif direction == 1:
  2770. move_x = 1
  2771. elif direction == 2:
  2772. move_y = 1
  2773. else:
  2774. move_x= -1
  2775. length = random.randint(step_min, step_max)
  2776. for m in range (0,length):
  2777. x = x + move_x
  2778. y = y + move_y
  2779. if x <= 1 or x >= 78 or y <= 1 or y >= 78:
  2780. break
  2781. run = False
  2782. self.tilemap[y][x] = replace_inner
  2783. for b in range (-1,2):
  2784. for a in range (-1,2):
  2785. 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:
  2786. self.tilemap[y+a][x+b] = replace_outer
  2787. run = False
  2788. def imp_connect(self,xpos,ypos,replace_inner,replace_except=None,except_replacer=None,style='straight'): #conects two or more points
  2789. for a in range (0,len(ypos)-1):
  2790. for b in range(0,len(xpos)-1):
  2791. y = ypos[a]
  2792. x = xpos[b]
  2793. go = True
  2794. direction = 0 #needed for natural ways. jumps between 0 and 1
  2795. while go:
  2796. try:
  2797. y_goal = ypos[a+1]
  2798. x_goal = xpos[b+1]
  2799. except:
  2800. y_goal = ypos[0]
  2801. x_goal = xpos[0]
  2802. if x == x_goal and y == y_goal:
  2803. go = False
  2804. if x_goal - x < 0: #find out if you need to go right or left
  2805. x_direction = -1
  2806. else:
  2807. x_direction = 1
  2808. if y_goal - y < 0: #find out if you need to go up or down
  2809. y_direction = -1
  2810. else:
  2811. y_direction = 1
  2812. if style == 'straight':
  2813. if x != x_goal:
  2814. x = x + x_direction
  2815. if self.tilemap[y][x] != replace_except:
  2816. self.tilemap[y][x] = replace_inner
  2817. elif self.tilemap[y][x] == replace_except:
  2818. self.tilemap[y][x] = except_replacer
  2819. elif y != y_goal:
  2820. y = y + y_direction
  2821. if self.tilemap[y][x] != replace_except:
  2822. self.tilemap[y][x] = replace_inner
  2823. elif self.tilemap[y][x] == replace_except:
  2824. self.tilemap[y][x] = except_replacer
  2825. elif style == 'natural':
  2826. if x != x_goal and direction == 0:
  2827. x = x + x_direction
  2828. if self.tilemap[y][x] != replace_except:
  2829. self.tilemap[y][x] = replace_inner
  2830. elif self.tilemap[y][x] == replace_except:
  2831. self.tilemap[y][x] = except_replacer
  2832. elif y != y_goal and direction == 1:
  2833. y = y + y_direction
  2834. if self.tilemap[y][x] != replace_except:
  2835. self.tilemap[y][x] = replace_inner
  2836. elif self.tilemap[y][x] == replace_except:
  2837. self.tilemap[y][x] = except_replacer
  2838. if direction == 0:
  2839. direction = 1
  2840. elif direction == 1:
  2841. direction = 0
  2842. def spawn_monsters(self,depth):
  2843. #This function spawns monsters on the map
  2844. if self.map_type == 'elfish_fortress':
  2845. monster_max = 0
  2846. for y in range(0,max_map_size):
  2847. for x in range(0,max_map_size):
  2848. if self.tilemap[y][x].techID == tl.tlist['functional'][8].techID:#this is a bed
  2849. monster_max += 1
  2850. else:
  2851. monster_max = (max_map_size*max_map_size)/30
  2852. monster_max = int(monster_max * self.monster_num)
  2853. if self.map_type == 'grot':
  2854. spawnpoints = self.find_all_moveable(ignore_water = False, ignore_no_spawn = False)
  2855. else:
  2856. spawnpoints = self.find_all_moveable(ignore_no_spawn = False)
  2857. del_list = []
  2858. monster_count = self.monster_count
  2859. for i in range (0,len(spawnpoints)):
  2860. if self.npcs[spawnpoints[i][1]][spawnpoints[i][0]] != 0: #there is a monster here
  2861. spawnpoints[i] = 'del'
  2862. #monster_count += 1#count the monsters that are already on the map
  2863. newlist = []
  2864. for k in spawnpoints:
  2865. if k != 'del':
  2866. newlist.append(k)
  2867. spawnpoints = newlist
  2868. monster_max -= monster_count
  2869. if monster_max > len(spawnpoints):
  2870. monster_max = len(spawnpoints)
  2871. for k in range(0,monster_max):
  2872. ran = random.randint(0,len(ml.mlist[self.map_type])-1)
  2873. ran2 = random.randint(0,len(spawnpoints)-1)
  2874. ran3 = random.randint(0,len(ml.mlist['civilian'])-1)
  2875. 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
  2876. self.set_monster_strength(spawnpoints[ran2][0],spawnpoints[ran2][1],depth)
  2877. self.monster_count += 1
  2878. if self.no_monster_respawn == False:
  2879. self.countdowns.append(countdown('spawner',spawnpoints[ran2][1],spawnpoints[ran2][0],random.randint(5,60)))
  2880. try:
  2881. if player.difficulty == 4:
  2882. self.npcs[spawnpoints[ran2][1]][spawnpoints[ran2][0]].AI_style = 'ignore'
  2883. except:
  2884. None
  2885. #set monsters personal_id
  2886. 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))
  2887. #set monster groups
  2888. self.spawn_monster_groups(ml.mlist['kobold'][0],ml.mlist['kobold'][1],9)#kobolds
  2889. def set_monster_strength(self,x,y,z,preset_lvl=None,lvl_bonus=0):
  2890. if self.npcs[y][x] != 0:
  2891. old_lvl = self.npcs[y][x].lvl
  2892. ran = random.randint(1,3)
  2893. if Time_ready == True:
  2894. if player.difficulty == 3:
  2895. base_lvl = 25
  2896. elif player.difficulty == 2:
  2897. base_lvl = 20
  2898. elif player.difficulty == 1:
  2899. base_lvl = 15
  2900. elif player.difficulty == 0:
  2901. base_lvl = 10
  2902. else:
  2903. base_lvl = 0
  2904. time_coeff = int(base_lvl*((time.year-1)*28*12 + time.day_total)/150) #base_lvl levels each 150 days of gameplay #
  2905. else:
  2906. time_coeff = 0
  2907. 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
  2908. try:
  2909. time_coeff = player.lvl
  2910. except:
  2911. None
  2912. monster_lvl = z + ran + self.monster_plus + time_coeff
  2913. if monster_lvl >= old_lvl and old_lvl > 0:
  2914. try:
  2915. screen.write_hit_matrix(x,y,12) #render monster_lvl_up
  2916. except:
  2917. None
  2918. if preset_lvl != None:
  2919. self.npcs[y][x].lvl = preset_lvl
  2920. else:
  2921. self.npcs[y][x].lvl = monster_lvl
  2922. self.npcs[y][x].lvl += lvl_bonus
  2923. attribute_list =[]
  2924. al = ('p_strength','p_defense','m_strength','m_defense','health')
  2925. for c in range(0,5):
  2926. if self.npcs[y][x].attribute_prev[c] > 0:
  2927. for h in range(0,self.npcs[y][x].attribute_prev[c]):
  2928. attribute_list.append(al[c])
  2929. for i in range(0,self.npcs[y][x].lvl):
  2930. choice = attribute_list[random.randint(0,len(attribute_list)-1)]
  2931. if choice == 'p_strength':
  2932. self.npcs[y][x].basic_attribute.p_strength +=3
  2933. elif choice == 'p_defense':
  2934. self.npcs[y][x].basic_attribute.p_defense +=3
  2935. elif choice == 'm_strength':
  2936. self.npcs[y][x].basic_attribute.m_strength +=3
  2937. elif choice == 'm_defense':
  2938. self.npcs[y][x].basic_attribute.m_defense +=3
  2939. elif choice == 'health':
  2940. self.npcs[y][x].basic_attribute.max_lp +=1
  2941. self.npcs[y][x].lp = self.npcs[y][x].basic_attribute.max_lp
  2942. if old_lvl == 0:
  2943. el = [['spear','sword','axe','hammer'],['rune','wand','rune staff','artefact'],['armor','armor'],['necklace','amulet','talisman'],['ring','ring']]
  2944. e_nr = 0
  2945. for q in range(0,len(el)-1):
  2946. ran = random.randint(0,len(el[q])-1)
  2947. if self.npcs[y][x].worn_equipment[q] == 1:
  2948. help_equipment = item_wear(el[q][ran],random.randint(0,min((z*3),21)),random.randint(-2,2))
  2949. self.npcs[y][x].basic_attribute.p_strength += help_equipment.attribute.p_strength
  2950. self.npcs[y][x].basic_attribute.p_defense += help_equipment.attribute.p_defense
  2951. self.npcs[y][x].basic_attribute.m_strength += help_equipment.attribute.m_strength
  2952. self.npcs[y][x].basic_attribute.m_defense += help_equipment.attribute.m_defense
  2953. self.npcs[y][x].basic_attribute.luck += help_equipment.attribute.luck
  2954. def make_vault(self,on_tile,depth):
  2955. run = True
  2956. while run:
  2957. pos = self.find_any(on_tile)
  2958. test = True
  2959. orientation = random.randint(0,3)#0:north, 1:east, 2:south, 3:west
  2960. try:
  2961. if pos[0] < 6 or pos[0] > max_map_size-6 or pos[1] < 6 or pos[1] > max_map_size-6:
  2962. test = False
  2963. if orientation == 0:
  2964. x_offset = -2
  2965. y_offset = random.randint(-1,1)
  2966. elif orientation == 1:
  2967. x_offset = random.randint(-1,1)
  2968. y_offset = -2
  2969. elif orientation == 2:
  2970. x_offset = 2
  2971. y_offste = random.randint(-1,1)
  2972. else:
  2973. x_offset = random.randint(-1,1)
  2974. y_offset = 2
  2975. for ty in range(pos[1]+y_offset-1,pos[1]+y_offset+6):
  2976. for tx in range(pos[0]+x_offset-1,pos[0]+x_offset+6):
  2977. if self.tilemap[ty][tx].techID == tl.tlist['dungeon'][0].techID:
  2978. test = False
  2979. elif self.tilemap[ty][tx].techID == tl.tlist['dungeon'][6].techID:
  2980. test = False
  2981. elif self.tilemap[ty][tx].techID == tl.tlist['dungeon'][9].techID:
  2982. test = False
  2983. elif self.tilemap[ty][tx].techID == tl.tlist['functional'][2].techID:
  2984. test = False
  2985. except:
  2986. test = False
  2987. if test:
  2988. run = False
  2989. for yy in range(pos[1]+y_offset-2,pos[1]+y_offset+3):
  2990. for xx in range(pos[0]+x_offset-2,pos[0]+x_offset+3):
  2991. 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:
  2992. self.tilemap[yy][xx] = deepcopy(tl.tlist['dungeon'][9])
  2993. self.tilemap[yy][xx].no_spawn = True
  2994. else:
  2995. self.tilemap[yy][xx] = deepcopy(tl.tlist['dungeon'][0])
  2996. self.tilemap[yy][xx].no_spawn = True
  2997. make_loot = True # if make_loot is set on False no gems or ore will spawn inside the vault
  2998. vault_center_x = pos[0]+x_offset
  2999. vault_center_y = pos[1]+y_offset
  3000. door_pos = self.drunken_finder(vault_center_x,vault_center_y,tl.tlist['dungeon'][9])
  3001. self.tilemap[door_pos[1]][door_pos[0]] = deepcopy(tl.tlist['dungeon'][6])
  3002. self.tilemap[door_pos[1]][door_pos[0]].no_spawn = True
  3003. vault_type = random.randint(0,4)
  3004. #vault_type = 4
  3005. if vault_type == 0: #Libary
  3006. replace = self.tilemap[vault_center_y][vault_center_x]
  3007. self.tilemap[vault_center_y][vault_center_x] = deepcopy(tl.tlist['functional'][19])#set a bookshelf
  3008. self.tilemap[vault_center_y][vault_center_x].replace = replace
  3009. self.tilemap[vault_center_y][vault_center_x].no_spawn = True
  3010. replace = self.tilemap[vault_center_y+1][vault_center_x]
  3011. self.tilemap[vault_center_y+1][vault_center_x] = deepcopy(tl.tlist['functional'][4])#set a chest
  3012. self.tilemap[vault_center_y+1][vault_center_x].replace = replace
  3013. self.tilemap[vault_center_y+1][vault_center_x].no_spawn = True
  3014. num_spellbooks = random.randint(2,3)#fill the chest
  3015. spellbook_list = []
  3016. 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])
  3017. for i in range(0,num_spellbooks):
  3018. ran = random.randint(0,len(sb)-1)
  3019. spellbook_list.append(sb[ran])
  3020. self.containers[vault_center_y+1][vault_center_x] = container(spellbook_list)
  3021. self.npcs[vault_center_y-1][vault_center_x-1] = deepcopy(ml.mlist['grot'][0]) #
  3022. self.set_monster_strength(vault_center_x-1,vault_center_y-1,depth,lvl_bonus=3) #
  3023. self.npcs[vault_center_y-1][vault_center_x+1] = deepcopy(ml.mlist['grot'][0]) #
  3024. self.set_monster_strength(vault_center_x+1,vault_center_y-1,depth,lvl_bonus=3) #set blue nagas
  3025. self.npcs[vault_center_y+1][vault_center_x-1] = deepcopy(ml.mlist['grot'][0]) #
  3026. self.set_monster_strength(vault_center_x-1,vault_center_y+1,depth,lvl_bonus=3) #
  3027. self.npcs[vault_center_y+1][vault_center_x+1] = deepcopy(ml.mlist['grot'][0]) #
  3028. self.set_monster_strength(vault_center_x+1,vault_center_y+1,depth,lvl_bonus=3) #
  3029. if vault_type == 1: #Slime pit
  3030. replace = self.tilemap[vault_center_y][vault_center_x]
  3031. self.tilemap[vault_center_y][vault_center_x] = deepcopy(tl.tlist['statue'][2])#set a blob statue
  3032. self.tilemap[vault_center_y][vault_center_x].replace = replace
  3033. self.tilemap[vault_center_y][vault_center_x].no_spawn = True
  3034. self.npcs[vault_center_y-1][vault_center_x-1] = deepcopy(ml.mlist['special'][10]) #
  3035. self.set_monster_strength(vault_center_x-1,vault_center_y-1,depth,lvl_bonus=3) #
  3036. self.npcs[vault_center_y-1][vault_center_x+1] = deepcopy(ml.mlist['special'][10]) #
  3037. self.set_monster_strength(vault_center_x+1,vault_center_y-1,depth,lvl_bonus=3) #set giant blobs
  3038. self.npcs[vault_center_y+1][vault_center_x-1] = deepcopy(ml.mlist['special'][10]) #
  3039. self.set_monster_strength(vault_center_x-1,vault_center_y+1,depth,lvl_bonus=3) #
  3040. self.npcs[vault_center_y+1][vault_center_x+1] = deepcopy(ml.mlist['special'][10]) #
  3041. self.set_monster_strength(vault_center_x+1,vault_center_y+1,depth,lvl_bonus=3) #
  3042. if vault_type == 2: #Kobold Lair
  3043. replace = self.tilemap[vault_center_y][vault_center_x]
  3044. self.tilemap[vault_center_y][vault_center_x] = deepcopy(tl.tlist['deco'][9])#set a stony throne
  3045. self.tilemap[vault_center_y][vault_center_x].replace = replace #
  3046. self.tilemap[vault_center_y][vault_center_x].no_spawn = True #
  3047. for posy in range(vault_center_y-1,vault_center_y+2): #
  3048. for posx in range(vault_center_x-1,vault_center_x+2): #set Kobolds
  3049. self.npcs[posy][posx] = deepcopy(ml.mlist['kobold'][1]) #
  3050. self.set_monster_strength(posx,posy,depth,lvl_bonus=3) #
  3051. self.npcs[vault_center_y][vault_center_x] = deepcopy(ml.mlist['kobold'][0]) #set kobold shaman
  3052. self.set_monster_strength(vault_center_x,vault_center_y,depth,lvl_bonus=3) #
  3053. if vault_type == 3: #Bat Cave
  3054. make_loot = False
  3055. for posy in range(vault_center_y-1,vault_center_y+2): #
  3056. for posx in range(vault_center_x-1,vault_center_x+2): #set bats
  3057. self.npcs[posy][posx] = deepcopy(ml.mlist['cave'][2]) #
  3058. self.set_monster_strength(posx,posy,depth) #
  3059. if vault_type == 4: #mimic chamber
  3060. make_loot = False
  3061. ranx = random.randint(-1,1) #
  3062. rany = random.randint(-1,1) #
  3063. replace = self.tilemap[vault_center_y+rany][vault_center_x+ranx] #
  3064. self.tilemap[vault_center_y+rany][vault_center_x+ranx] = deepcopy(tl.tlist['functional'][4])#set a chest
  3065. self.tilemap[vault_center_y+rany][vault_center_x+ranx].replace = replace #
  3066. self.tilemap[vault_center_y+rany][vault_center_x+ranx].no_spawn = True #
  3067. 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])
  3068. ransb = random.randint(0,len(sb)-1)
  3069. book = sb[ransb]
  3070. pick = item_wear('pickaxe', 20,0)
  3071. axe = item_wear('axe',20,0)
  3072. self.containers[vault_center_y+rany][vault_center_x+ranx] = container([book,axe,pick])#fill chest
  3073. for posy in range(vault_center_y-1,vault_center_y+2): #
  3074. for posx in range(vault_center_x-1,vault_center_x+2): #set sleeping mimics
  3075. if self.tilemap[posy][posx].techID != tl.tlist['functional'][4].techID: #
  3076. self.npcs[posy][posx] = deepcopy(ml.mlist['special'][3]) #
  3077. if make_loot == True:
  3078. for yyy in range(vault_center_y-2,vault_center_y+3):
  3079. for xxx in range(vault_center_x-2,vault_center_x+3):
  3080. if self.tilemap[yyy][xxx].techID == tl.tlist['dungeon'][0].techID:
  3081. ran2 = random.randint(0,2)
  3082. replace = self.tilemap[yyy][xxx]
  3083. if ran2 > 1:
  3084. self.tilemap[yyy][xxx] = deepcopy(tl.tlist['misc'][9])#set gem
  3085. self.tilemap[yyy][xxx].no_spawn = True
  3086. else:
  3087. self.tilemap[yyy][xxx] = deepcopy(tl.tlist['misc'][11])#set ore
  3088. self.tilemap[yyy][xxx].no_spawn = True
  3089. self.tilemap[yyy][xxx].replace = replace
  3090. #print('Made vault at: '+str(pos[0])+','+str(pos[1])+' Type:'+str(vault_type))
  3091. ####go on here
  3092. def make_orc_cave(self,on_tile):
  3093. run = True
  3094. while run:
  3095. pos = self.find_any(on_tile)
  3096. test = True
  3097. try:
  3098. for ty in range(pos[1]-2,pos[1]+3):
  3099. for tx in range(pos[0]-2,pos[0]+3):
  3100. if self.tilemap[ty][tx].techID == tl.tlist['misc'][16]:
  3101. test = False
  3102. elif self.tilemap[ty][tx].techID == tl.tlist['mine'][0]:
  3103. test = False
  3104. elif self.tilemap[ty][tx].techID == tl.tlist['dungeon'][3]:
  3105. test = False
  3106. elif self.tilemap[ty][tx].techID == tl.tlist['misc'][12]:
  3107. test = False
  3108. except:
  3109. test = False
  3110. if ((pos[0]-(max_map_size/2))**2+(pos[1]-(max_map_size/2))**2)**0.5 > 10:
  3111. 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:
  3112. run = False
  3113. for y in range(pos[1]-2,pos[1]+3):
  3114. for x in range(pos[0]-2,pos[0]+3):
  3115. self.tilemap[y][x] = tl.tlist['misc'][16] #fill with solid orcish wall
  3116. for y in range(pos[1]-1,pos[1]+2):
  3117. for x in range(pos[0]-1,pos[0]+2):
  3118. self.tilemap[y][x] = tl.tlist['mine'][0] #fill inner with orcish mine floor
  3119. if x != pos[0] or y != pos[1]:
  3120. self.npcs[y][x] = deepcopy(ml.mlist['orc'][random.randint(0,len(ml.mlist['orc'])-1)]) #
  3121. else: #
  3122. self.npcs[y][x] = deepcopy(ml.mlist['orcish_mines'][1]) #
  3123. self.set_monster_strength(x,y,1) #generate orcs
  3124. self.countdowns.append(countdown('orc_spawner',x,y,random.randint(5,60))) #
  3125. self.tilemap[pos[1]-2][pos[0]] = deepcopy(tl.tlist['dungeon'][3])#
  3126. self.tilemap[pos[1]+2][pos[0]] = deepcopy(tl.tlist['dungeon'][3])# make dungeon doors
  3127. self.tilemap[pos[1]][pos[0]-2] = deepcopy(tl.tlist['dungeon'][3])#
  3128. self.tilemap[pos[1]][pos[0]+2] = deepcopy(tl.tlist['dungeon'][3])#
  3129. self.tilemap[pos[1]-2][pos[0]-2] = deepcopy(tl.tlist['misc'][12])#
  3130. self.tilemap[pos[1]-2][pos[0]-2].replace = deepcopy(on_tile) #
  3131. self.tilemap[pos[1]-2][pos[0]+2] = deepcopy(tl.tlist['misc'][12])#
  3132. self.tilemap[pos[1]-2][pos[0]+2].replace = deepcopy(on_tile) # add orc deko to the connors
  3133. self.tilemap[pos[1]+2][pos[0]-2] = deepcopy(tl.tlist['misc'][12])#
  3134. self.tilemap[pos[1]+2][pos[0]-2].replace = deepcopy(on_tile) #
  3135. self.tilemap[pos[1]+2][pos[0]+2] = deepcopy(tl.tlist['misc'][12])#
  3136. self.tilemap[pos[1]+2][pos[0]+2].replace = deepcopy(on_tile) #
  3137. self.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['misc'][18])#set a crystal orb
  3138. def AI_move(self):
  3139. #This function moves all monsters that are 7 or less fields away from the player.
  3140. #It dosn't move all monsters to save performance
  3141. ymin = player.pos[1]-7
  3142. if ymin < 0:
  3143. ymin = 0
  3144. xmin = player.pos[0]-7
  3145. if xmin < 0:
  3146. xmin = 0
  3147. ymax = player.pos[1]+8
  3148. if ymax > max_map_size:
  3149. ymax = max_map_size
  3150. xmax = player.pos[0]+8
  3151. if xmax > max_map_size:
  3152. xmax = max_map_size
  3153. for y in range (ymin,ymax):#reset the move_done switches
  3154. for x in range (xmin,xmax):
  3155. if self.npcs[y][x] != 0:
  3156. if self.npcs[y][x].lp > 0:
  3157. self.npcs[y][x].move_done = 0
  3158. else:
  3159. test = False
  3160. while test == False:
  3161. test = self.monster_die(x,y)
  3162. for y in range (ymin,ymax):
  3163. for x in range (xmin,xmax):
  3164. if self.npcs[y][x] != 0 and self.npcs[y][x].move_done == 0:#if there is a monster at this place
  3165. #I. Get possible fields for a move
  3166. moves = [(x,y)]
  3167. yy = (-1,0,0,1)
  3168. xx = (0,-1,1,0)
  3169. for i in range (0,4):
  3170. try:
  3171. monster_move_groups = self.npcs[y][x].move_groups
  3172. tile_move_group = self.tilemap[y+yy[i]][x+xx[i]].move_group
  3173. move_group_check = tile_move_group in monster_move_groups
  3174. if self.npcs[y+yy[i]][x+xx[i]] == 0:
  3175. npc = False
  3176. else:
  3177. npc = True
  3178. 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
  3179. stair = True
  3180. else:
  3181. stair = False
  3182. if x + xx[i] == player.pos[0] and y + yy[i] == player.pos[1]:
  3183. playerpos = True
  3184. else:
  3185. playerpos = False
  3186. if move_group_check == True and npc == False and stair == False and playerpos == False:
  3187. moves.append((x+xx[i],y+yy[i]))
  3188. except:
  3189. print('Debug:Error')
  3190. #II. Find out which possible move leads to which distance between monster and player
  3191. distances = []
  3192. for j in range (0,len(moves)):
  3193. a = player.pos[0] - moves[j][0]
  3194. b = player.pos[1] - moves[j][1]
  3195. c = (a**2 + b**2)**0.5 # this is just the good old pythagoras (c² = a² + b²)
  3196. distances.append(c)
  3197. #III. Choose the right move (or special action)
  3198. do_move = 'foo'
  3199. if self.npcs[y][x].AI_style == 'hostile':
  3200. ability_keys = self.npcs[y][x].ability.keys()
  3201. 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
  3202. if 'def_teleport' in ability_keys:
  3203. ran = random.randint(0,99)
  3204. if ran < self.npcs[y][x].ability['def_teleport'] and self.npcs[y][x].move_done != 1:
  3205. moves = self.find_all_moveable(ignore_player_pos = False)
  3206. if moves != False:
  3207. if len(moves) == 1:
  3208. pos_num = 0
  3209. else:
  3210. pos_num = random.randint(0,len(moves)-1)
  3211. self.npcs[y][x].move_done = 1
  3212. self.npcs[y][x].num_special -= 1
  3213. tp_string = 'A ' + self.npcs[y][x].name + ' teleports.'
  3214. message.add(tp_string)
  3215. screen.write_hit_matrix(x,y,7)
  3216. sfx.play('teleport')
  3217. self.npcs[moves[pos_num][1]][moves[pos_num][0]] = self.npcs[y][x]
  3218. self.npcs[y][x] = 0
  3219. if 'def_flee' in ability_keys:
  3220. ran = random.randint(0,99)
  3221. if self.npcs[y][x] != 0:
  3222. if ran < self.npcs[y][x].ability['def_flee'] and self.npcs[y][x].move_done != 1 and self.npcs[y][x].lp < self.npcs[y][x].basic_attribute.max_lp:
  3223. flee_string = 'A ' + self.npcs[y][x].name + ' turns to flee.'
  3224. message.add(flee_string)
  3225. self.npcs[y][x].AI_style = 'flee'
  3226. self.npcs[y][x].move_done = 1
  3227. self.npcs[y][x].num_special -= 1
  3228. if 'def_potion' in ability_keys:
  3229. ran = random.randint(0,99)
  3230. if ran < self.npcs[y][x].ability['def_potion'] and self.npcs[y][x].move_done != 1:
  3231. if self.npcs[y][x].lp < self.npcs[y][x].basic_attribute.max_lp:
  3232. potion_string = 'A ' + self.npcs[y][x].name + ' quaffes a potion of healing.'
  3233. message.add(potion_string)
  3234. screen.write_hit_matrix(x,y,6)
  3235. lp = min(self.npcs[y][x].basic_attribute.max_lp, self.npcs[y][x].lp+7)
  3236. self.npcs[y][x].lp = lp
  3237. sfx.play('drink')
  3238. self.npcs[y][x].move_done = 1
  3239. self.npcs[y][x].num_special -= 1
  3240. if self.npcs[y][x] != 0:
  3241. 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
  3242. if 'spawn' in ability_keys: #the value of spawn is a tulpel with 2 elements; 0: chance that something is spawned 1: number that determines what is spawned
  3243. ran = random.randint(0,99)
  3244. if ran < self.npcs[y][x].ability['spawn'][0]:
  3245. spawn_kind = self.npcs[y][x].ability['spawn'][1]
  3246. xlist = []
  3247. ylist = []
  3248. for yy in range(y-1,y+2):
  3249. for xx in range(x-1,x+2):
  3250. if self.tilemap[yy][xx].move_group == 'soil' and self.npcs[yy][xx] == 0:
  3251. xlist.append(xx)
  3252. ylist.append(yy)
  3253. if len(xlist) == len(ylist) and len(xlist) > 0:
  3254. if len(xlist) > 1:
  3255. num = random.randint(0,len(xlist)-1)
  3256. else:
  3257. num = 0
  3258. if 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'][spawn_kind]) #all spawnlings must be a part of ml.mlist['special']
  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 ' + ml.mlist['special'][spawn_kind].name + '.'
  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. if 'blink' in ability_keys:
  3269. ran = random.randint(0,99)
  3270. if ran < self.npcs[y][x].ability['blink'] and self.npcs[y][x].move_done != 1 and self.npcs[y][x].num_special > 0:
  3271. xlist = []
  3272. ylist = []
  3273. for yy in range(player.pos[1]-3,player.pos[1]+4):
  3274. for xx in range(player.pos[0]-3,player.pos[0]+4):
  3275. if self.tilemap[yy][xx].move_group in self.npcs[y][x].move_groups and self.npcs[yy][xx] == 0:
  3276. if yy != player.pos[1] or xx != player.pos[0]:
  3277. xlist.append(xx)
  3278. ylist.append(yy)
  3279. if len(xlist) != 0:
  3280. try:
  3281. rand = random.randint(0,len(xlist)-1)
  3282. except:
  3283. rand = 0
  3284. screen.write_hit_matrix(x,y,7)
  3285. screen.write_hit_matrix(xlist[rand],ylist[rand],7)
  3286. mes = 'A '+self.npcs[y][x].name+' blinks!'
  3287. message.add(mes)
  3288. self.npcs[ylist[rand]][xlist[rand]] = self.npcs[y][x]
  3289. self.npcs[y][x] = 0
  3290. self.npcs[ylist[rand]][xlist[rand]].num_special -= 1
  3291. self.npcs[ylist[rand]][xlist[rand]].move_done = 1
  3292. if x == player.pos[0] or y == player.pos[1]:
  3293. straight_line = True
  3294. else:
  3295. straight_line = False
  3296. shoot = False
  3297. throw = False
  3298. if 'range_shoot' in ability_keys:
  3299. shoot = True
  3300. elif 'range_throw' in ability_keys:
  3301. throw = True
  3302. if self.npcs[y][x] != 0 and straight_line == True and (shoot == True or throw == True) and distances[0] < 5:
  3303. #Step 0: Random
  3304. if shoot == True:
  3305. chance = self.npcs[y][x].ability['range_shoot']
  3306. else:
  3307. chance = self.npcs[y][x].ability['range_throw'][0]
  3308. ran = random.randint(0,99)
  3309. if ran < chance and self.npcs[y][x].num_special > 0 and self.npcs[y][x].move_done != 1:
  3310. #Step 1: find the right direction
  3311. if y > player.pos[1]:
  3312. y_dir = -1
  3313. elif y < player.pos[1]:
  3314. y_dir = 1
  3315. else:
  3316. y_dir = 0
  3317. if x > player.pos[0]:
  3318. x_dir = -1
  3319. elif x < player.pos[0]:
  3320. x_dir = 1
  3321. else:
  3322. x_dir = 0
  3323. #Step 2: Check for borders
  3324. run = True
  3325. count = 1
  3326. fire_free = True
  3327. while run:
  3328. cx = x + (count*x_dir)
  3329. cy = y + (count*y_dir)
  3330. if self.tilemap[cy][cx].transparency == False:
  3331. fire_free = False
  3332. run = False
  3333. count +=1
  3334. if cx == player.pos[0] and cy == player.pos[1]:
  3335. run = False
  3336. #Step 3: Fire!
  3337. if fire_free == True:
  3338. run = True
  3339. count = 1
  3340. if 'range_shoot' in ability_keys:
  3341. sfx.play('fire')
  3342. else:
  3343. sfx.play('miss')
  3344. while run:
  3345. xx = x + (count*x_dir)
  3346. yy = y + (count*y_dir)
  3347. if xx != player.pos[0] or yy != player.pos[1]:
  3348. screen.write_hit_matrix(xx,yy,2)
  3349. if self.tilemap[yy][xx].transparency == False:
  3350. screen.write_hit_matrix(player.pos[0],player.pos[1],3)
  3351. if 'range_throw' in ability_keys:
  3352. sfx.play('throw')
  3353. run = False
  3354. else:
  3355. if shoot == True:#----------> go on here!!!!!!!!
  3356. self.npcs[y][x].move_done = 1
  3357. player.monster_attacks(x,y)
  3358. elif self.npcs[y][x].ability['range_throw'][1] == 'stone':
  3359. self.npcs[y][x].move_done = 1
  3360. message.add('A '+self.npcs[y][x].name+' throws a stone!')
  3361. chance = 9 - count
  3362. coin = random.randint(0,9)
  3363. if coin < chance:
  3364. sfx.play('hit')
  3365. screen.write_hit_matrix(player.pos[0],player.pos[1],4)
  3366. message.add('The stone hits you.(1 damage)')
  3367. player.lp -= 1
  3368. else:
  3369. sfx.play('throw')
  3370. screen.write_hit_matrix(player.pos[0],player.pos[1],3)
  3371. message.add('The stone misses you.')
  3372. elif self.npcs[y][x].ability['range_throw'][1] == 'dart':
  3373. self.npcs[y][x].move_done = 1
  3374. message.add('A '+self.npcs[y][x].name+' throws a dart!')
  3375. chance = 9 - count
  3376. coin = random.randint(0,9)
  3377. if coin < chance:
  3378. sfx.play('hit')
  3379. screen.write_hit_matrix(player.pos[0],player.pos[1],4)
  3380. message.add('The dart hits you.(2 damage)')
  3381. player.lp -= 2
  3382. else:
  3383. sfx.play('throw')
  3384. screen.write_hit_matrix(player.pos[0],player.pos[1],3)
  3385. message.add('The dart misses you.')
  3386. elif self.npcs[y][x].ability['range_throw'][1] == 'knife':
  3387. self.npcs[y][x].move_done = 1
  3388. message.add('A '+self.npcs[y][x].name+' throws a throwing knife')
  3389. chance = 9 - count
  3390. coin = random.randint(0,9)
  3391. if coin < chance:
  3392. sfx.play('hit')
  3393. screen.write_hit_matrix(player.pos[0],player.pos[1],4)
  3394. message.add('The throwing knife hits you.(3 damage)')
  3395. player.lp -= 3
  3396. else:
  3397. sfx.play('throw')
  3398. screen.write_hit_matrix(player.pos[0],player.pos[1],3)
  3399. message.add('The throwing knife misses you.')
  3400. run = False
  3401. count += 1
  3402. self.npcs[y][x].move_done = 1
  3403. if 'range_throw' in ability_keys:
  3404. self.npcs[y][x].num_special -= 1
  3405. if self.npcs[y][x] != 0 and self.npcs[y][x].move_done == 0:
  3406. if len(moves) > 0:#if no move is possible at least the 'move' of stay still must remain
  3407. good_moves = []
  3408. for k in range (0, len(moves)):
  3409. if distances[k] < distances[0]:#if the possible move makes the distance between player and monster smaller
  3410. good_moves.append(moves[k])
  3411. else:
  3412. good_moves = moves
  3413. if len(good_moves) == 0:
  3414. good_moves = moves
  3415. if len(good_moves) > 1:
  3416. ran = random.randint(0,len(good_moves)-1)
  3417. else:
  3418. ran = 0
  3419. do_move = good_moves[ran]
  3420. else:
  3421. if self.npcs[y][x].move_done == 0:
  3422. #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.
  3423. if player.inventory.materials.gem > 0 and 'close_steal' in ability_keys:
  3424. ran = random.randint(0,99)
  3425. if ran < self.npcs[y][x].ability['close_steal']:
  3426. player.inventory.materials.gem -= 1
  3427. self.npcs[y][x].corps_lvl += 1
  3428. screen.write_hit_matrix(player.pos[0],player.pos[1],8)
  3429. screen.write_hit_matrix(x,y,9)
  3430. sfx.play('steal')
  3431. steal_string = 'A ' + self.npcs[y][x].name + ' steals a gem from you.'
  3432. message.add(steal_string)
  3433. self.npcs[y][x].move_done = 1#set the move_done switch on
  3434. if self.npcs[y][x].move_done == 0:
  3435. #casting flames
  3436. if 'close_flames' in ability_keys:
  3437. ran = random.randint(0,99)
  3438. if ran < self.npcs[y][x].ability['close_flames'] and self.npcs[y][x].num_special > 0:
  3439. #Step 0: Check if any (other) monsters are near by
  3440. sfx.play('flame')
  3441. monster_num = 0
  3442. for yy in range(y-1,y+2):
  3443. for xx in range(x-1,x+2):
  3444. if self.npcs[yy][xx] != 0:
  3445. monster_num += 1
  3446. if monster_num == 1:#there is no other monster near by
  3447. num_flames = 0
  3448. for yyy in range(y-1,y+2):
  3449. for xxx in range(x-1,x+2):
  3450. if xxx != x or yyy != y:
  3451. 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':
  3452. replace = self.tilemap[yyy][xxx]
  3453. self.tilemap[yyy][xxx] = deepcopy(tl.tlist['effect'][4])
  3454. self.tilemap[yyy][xxx].replace = replace
  3455. self.countdowns.append(countdown('flame',xxx,yyy,3))
  3456. num_flames+=1
  3457. if num_flames > 0:
  3458. flame_string = 'A '+ self.npcs[y][x].name + ' casts a flame spell!'
  3459. message.add(flame_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. #vampirism
  3464. if 'close_vampirism' in ability_keys:
  3465. ran = random.randint(0,99)
  3466. if ran < self.npcs[y][x].ability['close_vampirism']:
  3467. player.lp -= 1
  3468. self.npcs[y][x].lp += 1
  3469. screen.write_hit_matrix(player.pos[0],player.pos[1],18)
  3470. screen.write_hit_matrix(x,y,19)
  3471. sfx.play('vampire')
  3472. vamp_string = 'A ' + self.npcs[y][x].name +' sucks your blood.'
  3473. message.add(vamp_string)
  3474. self.npcs[y][x].num_special -= 1
  3475. self.npcs[y][x].move_done = 1
  3476. if self.npcs[y][x].move_done == 0 and self.npcs[y][x].num_special > 0:
  3477. #steal items
  3478. if 'close_stealItem' in ability_keys:
  3479. ran = random.randint(0,99)
  3480. if ran < self.npcs[y][x].ability['close_stealItem']:
  3481. #0: Find parent
  3482. parent_pos = False
  3483. parent_id = self.npcs[y][x].personal_id.replace('_child','')
  3484. for yy in range(0,max_map_size):
  3485. for xx in range(0,max_map_size):
  3486. if self.npcs[yy][xx] != 0 and self.npcs[yy][xx].personal_id == parent_id:
  3487. parent_pos = (xx,yy)
  3488. #1: Check Parent Status
  3489. if parent_pos != False:
  3490. if len(self.containers[parent_pos[1]][parent_pos[0]].items) < 7:
  3491. p_check = True
  3492. else:
  3493. p_check = False
  3494. #2: Steal Item
  3495. if p_check == True:
  3496. all_bp = ('Head','Body','Legs','Feet','Hold(R)','Hold(L)','Neck','Axe','Pickaxe','Hand')
  3497. final_bp = ['None',]
  3498. for i in range(0,len(all_bp)-1):
  3499. if player.inventory.wearing[all_bp[i]] != player.inventory.nothing:
  3500. final_bp.append(all_bp[i])
  3501. del final_bp[0]
  3502. if len(final_bp) > 0:
  3503. if len(final_bp) == 1:
  3504. ran = 0
  3505. else:
  3506. ran = random.randint(0,len(final_bp)-1)
  3507. item = player.inventory.wearing[final_bp[ran]]
  3508. player.inventory.wearing[final_bp[ran]] = player.inventory.nothing
  3509. self.containers[parent_pos[1]][parent_pos[0]].items.append(item)
  3510. mes = 'A '+self.npcs[y][x].name+' steals your '+item.name+'!'
  3511. message.add(mes)
  3512. sfx.play('steal')
  3513. screen.write_hit_matrix(player.pos[0],player.pos[1],21)
  3514. screen.write_hit_matrix(parent_pos[0],parent_pos[1],22)
  3515. self.npcs[y][x].lp = 0
  3516. if self.npcs[y][x].move_done == 0 and self.npcs[y][x].num_special > 0:
  3517. #throw explosives
  3518. if 'close_throwExplosive' in ability_keys:
  3519. ran = random.randint(0,99)
  3520. if ran < self.npcs[y][x].ability['close_throwExplosive']:
  3521. positions = []
  3522. for yy in range(player.pos[1]-1,player.pos[1]+2):
  3523. for xx in range(player.pos[0]-1,player.pos[0]+2):
  3524. if self.tilemap[yy][xx].replace == None and self.tilemap[yy][xx].move_group == 'soil' and self.tilemap[yy][xx].use_group == 'None':
  3525. positions.append((xx,yy))
  3526. if len(positions) > 0:
  3527. sfx.play('throw')
  3528. screen.write_hit_matrix(x,y,20)
  3529. ran = random.randint(0,len(positions)-1)
  3530. pos = positions[ran]
  3531. screen.write_hit_matrix(pos[0],pos[1],16)
  3532. coin = random.randint(0,3)
  3533. if coin == 0:
  3534. message.add('A '+self.npcs[y][x].name+' throws a bomb!')
  3535. replace = self.tilemap[pos[1]][pos[0]]
  3536. self.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['effect'][0])
  3537. self.countdowns.append(countdown('bomb3',pos[0],pos[1],1))
  3538. self.tilemap[pos[1]][pos[0]].replace = replace
  3539. else:
  3540. message.add('A '+self.npcs[y][x].name+' throws an explosive!')
  3541. replace = self.tilemap[pos[1]][pos[0]]
  3542. self.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['effect'][7])
  3543. self.tilemap[pos[1]][pos[0]].replace = replace
  3544. self.npcs[y][x].move_done = 1
  3545. self.npcs[y][x].num_special -= 1
  3546. if self.npcs[y][x].move_done == 0:
  3547. player.monster_attacks(x,y)
  3548. self.npcs[y][x].move_done = 1#set the move_done switch on
  3549. elif self.npcs[y][x].AI_style == 'flee':
  3550. 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
  3551. if len(moves) > 1:
  3552. ran = random.randint(0,len(moves)-1)
  3553. else:
  3554. ran = 0
  3555. do_move = moves[ran]
  3556. else:
  3557. if len(moves) > 0:#if no move is possible at least the 'move' of stay still must remain
  3558. good_moves = []
  3559. for k in range (0, len(moves)):
  3560. 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
  3561. good_moves.append(moves[k])
  3562. else:
  3563. good_moves = moves
  3564. if len(good_moves) == 0:
  3565. good_moves = moves
  3566. if len(good_moves) > 1:
  3567. ran = random.randint(0,len(good_moves)-1)
  3568. else:
  3569. ran = 0
  3570. do_move = good_moves[ran]
  3571. elif self.npcs[y][x].AI_style == 'ignore':
  3572. if len(moves) > 1:
  3573. ran = random.randint(0,len(moves)-1)
  3574. else:
  3575. ran = 0
  3576. do_move = moves[ran]
  3577. #IV. Move the monster
  3578. if do_move != 'foo':
  3579. border = random.randint(1,9)
  3580. if border > self.npcs[y][x].move_border:
  3581. self.npcs[y][x].move_done = 1#set the move_done switch on
  3582. helper = self.npcs[y][x]#copy the monster
  3583. self.npcs[y][x] = 0 #del the monster at the old position
  3584. self.npcs[do_move[1]][do_move[0]] = helper# set monster to the new position
  3585. def monster_die(self,x,y,xp = None):
  3586. #this function is called when the player kills a monster. the x and the y variables are to define the location of the monster
  3587. monster_x = x
  3588. monster_y = y
  3589. real_drop = False
  3590. if self.tilemap[y][x].replace == None:
  3591. test_replace = True
  3592. else:
  3593. test_replace = False
  3594. if self.npcs[monster_y][monster_x].corps_style == 'make_blobs':
  3595. test_replace = True
  3596. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' vanishes!'
  3597. if test_replace != True or self.tilemap[y][x].drops_here != True:
  3598. location_list = [(monster_x,monster_y),]
  3599. for yy in range(y-1,y+2):
  3600. for xx in range(x-1,x+2):
  3601. if self.tilemap[yy][xx].replace == None and self.npcs[yy][xx] == 0:
  3602. test_replace = True
  3603. else:
  3604. test_replace = False
  3605. if test_replace == True and self.tilemap[yy][xx].drops_here and self.tilemap[yy][xx].move_group == 'soil' and self.containers[yy][xx] == 0:
  3606. location_list.append((xx,yy))
  3607. if len(location_list) > 1:
  3608. del location_list[0]
  3609. if len(location_list) == 1:
  3610. x = location_list[0][0]
  3611. y = location_list[0][1]
  3612. else:
  3613. ran = random.randint(0,len(location_list)-1)
  3614. x = location_list[ran][0]
  3615. y = location_list[ran][1]
  3616. if test_replace == True and self.tilemap[y][x].drops_here: #only on empty fields corps can be spawned
  3617. 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
  3618. coin = random.randint(0,99)
  3619. if coin < 50:#there is a chance of 50%
  3620. replace = self.tilemap[y][x]
  3621. self.tilemap[y][x] = tl.tlist['local'][10]#<---sepling
  3622. self.tilemap[y][x].replace = replace
  3623. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' turns into a new tree!'
  3624. 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
  3625. coin = random.randint(0,99)
  3626. if coin < 50:#there is a chance of 50%
  3627. replace = self.tilemap[y][x]
  3628. self.tilemap[y][x] = deepcopy(tl.tlist['local'][14])#<---rock
  3629. self.tilemap[y][x].replace = replace
  3630. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' turns to stone!'
  3631. 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
  3632. coin = random.randint(0,99)
  3633. if coin < 15:#there is a chance of 15%
  3634. real_drop = True
  3635. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' dies!'
  3636. replace = self.tilemap[y][x]
  3637. self.tilemap[y][x] = deepcopy(tl.tlist['functional'][6])#<--humanoid remains
  3638. self.tilemap[y][x].replace = replace
  3639. items = []
  3640. max_items = max(1,self.npcs[monster_y][monster_x].corps_lvl)
  3641. for i in range (0, max_items):
  3642. #possible drops of a humanoid monster are equipment items and food items
  3643. coin = random.randint(0,99)
  3644. if coin < 65: #there is a chance of 65% that a item becomes a eqipment item
  3645. material = random.randint(0,20) #all materials are allowed
  3646. classes = ('spear','sword','axe','hammer','shoes','cuisse','helmet','armor','wand','rune','rune staff','artefact','ring','amulet','necklace','talisman','pickaxe')
  3647. kind = classes[random.randint(0,len(classes)-1)]#all classes of objects are allowed
  3648. plus = random.randint(-2,+2)# a plus between -2 and +2 is possible
  3649. state = random.randint(10,85)#the state of this used objects will always be between 10% and 80%
  3650. curse_chance = random.randint(0,30)
  3651. if curse_chance < material:
  3652. curse = 0
  3653. elif curse_chance == material:
  3654. curse = 2
  3655. else:
  3656. curse = 1
  3657. item = item_wear(kind,material,plus,state,curse)
  3658. elif coin < 68: #there is a chance of 3% to drop a simple blueprint
  3659. blueprint = random.randint(15,20)
  3660. item = deepcopy(il.ilist['misc'][blueprint])
  3661. elif coin < 80: #there is a chance of 12% to drop a torch or a throwable:
  3662. 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])
  3663. ran = random.randint(0,len(item_list)-1)
  3664. item = deepcopy(item_list[ran])
  3665. else:
  3666. coin2 = random.randint(0,1)
  3667. if coin == 1:
  3668. item = deepcopy(il.ilist['food'][random.randint(0,len(il.ilist['food'])-1)])
  3669. else:
  3670. item_list = (il.ilist['misc'][74],il.ilist['misc'][75],il.ilist['misc'][76],il.ilist['misc'][77])
  3671. ran = random.randint(0,len(item_list)-1)
  3672. item = deepcopy(item_list[ran])
  3673. items.append(item)
  3674. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  3675. 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
  3676. coin = random.randint(0,99)
  3677. if coin < 15:#there is a chance of 15%
  3678. real_drop = True
  3679. replace = self.tilemap[y][x]
  3680. self.tilemap[y][x] = deepcopy(tl.tlist['functional'][21])#<--animal remains
  3681. self.tilemap[y][x].replace = replace
  3682. items = []
  3683. max_items = max(1,self.npcs[monster_y][monster_x].corps_lvl)
  3684. for i in range (0, max_items):
  3685. #animals drop flesh. the corpslvl says how much
  3686. items.append(deepcopy(il.ilist['food'][9]))#<---raw meat
  3687. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  3688. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' dies!'
  3689. 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
  3690. coin = random.randint(0,99)
  3691. if coin < 10:#there is a chance of 10%
  3692. real_drop = True
  3693. die_mess = 'The ' + self.npcs[monster_y][monster_x].name + ' dies!'
  3694. replace = self.tilemap[y][x]
  3695. self.tilemap[y][x] = deepcopy(tl.tlist['functional'][6])#<--humanoid remains
  3696. self.tilemap[y][x].replace = replace
  3697. items = []
  3698. max_items = max(1,self.npcs[monster_y][monster_x].corps_lvl)
  3699. for i in range (0, max_items):
  3700. #possible drops of a scrollkeeper are scrolls and spellbooks
  3701. coin = random.randint(0,99)
  3702. if coin < 75: #there is a chance of 75% that a item becomes a scroll
  3703. 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])
  3704. ran = random.randint(0,len(scrolls)-1)
  3705. item = deepcopy(scrolls[ran])
  3706. else:
  3707. 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])
  3708. ran = random.randint(0,len(books)-1)
  3709. item = deepcopy(books[ran])
  3710. items.append(item)
  3711. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  3712. elif self.npcs[monster_y][monster_x].corps_style == 'miner':
  3713. if self.npcs[monster_y][monster_x].techID == ml.mlist['special'][0].techID:#this is a vase
  3714. die_mess = 'The vase shatters.'
  3715. ran = random.randint(0,99)
  3716. if ran <= self.npcs[monster_y][monster_x].corps_lvl: #for miners the corps_lvl determinates the chance of getting a gem
  3717. real_drop = True
  3718. replace = self.tilemap[y][x]
  3719. self.tilemap[y][x] = deepcopy(tl.tlist['misc'][9])#set a lost gem
  3720. self.tilemap[y][x].replace = replace
  3721. 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
  3722. real_drop = True
  3723. replace = self.tilemap[y][x]
  3724. self.tilemap[y][x] = deepcopy(tl.tlist['misc'][11])#set a lost ore
  3725. self.tilemap[y][x].replace = replace
  3726. elif self.npcs[monster_y][monster_x].corps_style == 'thief':
  3727. if self.tilemap[y][x].replace == None and self.npcs[monster_y][monster_x].corps_lvl > 0:
  3728. real_drop = True
  3729. replace = self.tilemap[y][x]
  3730. self.tilemap[y][x] = deepcopy(tl.tlist['misc'][9])#set a lost gem
  3731. self.tilemap[y][x].replace = replace
  3732. 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
  3733. elif self.npcs[monster_y][monster_x].corps_style == 'reset_parent':
  3734. parent_id = self.npcs[monster_y][monster_x].personal_id.replace('_child','')
  3735. for yy in range(0,max_map_size):
  3736. for xx in range(0,max_map_size):
  3737. if self.npcs[yy][xx] != 0:
  3738. if self.npcs[yy][xx].personal_id == parent_id:
  3739. self.npcs[yy][xx].num_special += 1
  3740. elif self.npcs[monster_y][monster_x].corps_style == 'kill_childs':
  3741. child_id = self.npcs[monster_y][monster_x].personal_id + '_child'
  3742. for yy in range(0,max_map_size):
  3743. for xx in range(0,max_map_size):
  3744. if self.npcs[yy][xx] != 0:
  3745. if self.npcs[yy][xx].personal_id == child_id:
  3746. self.npcs[yy][xx] = 0
  3747. elif self.npcs[monster_y][monster_x].corps_style == 'kobold_fear':
  3748. for yy in range(y-7,y+8):
  3749. for xx in range(x-7,x+8):
  3750. try:
  3751. if self.npcs[yy][xx].techID == ml.mlist['kobold'][1].techID and self.npcs[yy][xx].name != 'frightened kobold':
  3752. self.npcs[yy][xx] = deepcopy(self.npcs[yy][xx])#only to be sure
  3753. self.npcs[yy][xx].name = 'frightened kobold'
  3754. self.npcs[yy][xx].sprite_pos = (5,3)
  3755. self.npcs[yy][xx].basic_attribute.p_strength = int(self.npcs[yy][xx].basic_attribute.p_strength*0.6)
  3756. self.npcs[yy][xx].basic_attribute.m_strength = int(self.npcs[yy][xx].basic_attribute.m_strength*0.6)
  3757. self.npcs[yy][xx].basic_attribute.p_defense = int(self.npcs[yy][xx].basic_attribute.p_defense*0.6)
  3758. self.npcs[yy][xx].basic_attribute.m_defense = int(self.npcs[yy][xx].basic_attribute.m_defense*0.6)
  3759. screen.write_hit_matrix(xx,yy,17)
  3760. coin = random.randint(0,1)
  3761. if coin == 1:
  3762. self.npcs[yy][xx].AI_style = 'flee'
  3763. except:
  3764. None
  3765. elif self.npcs[monster_y][monster_x].corps_style == 'vase':
  3766. die_mess = 'The vase shatters and monsters jump out.'
  3767. monster_count = 0
  3768. for yy in range(y-1,y+2):
  3769. for xx in range(x-1,x+2):
  3770. if yy != player.pos[1] or xx!= player.pos[0]:
  3771. if self.npcs[yy][xx] == 0 and self.tilemap[yy][xx].move_group == 'soil' and self.tilemap[yy][xx].damage == 0:
  3772. self.npcs[yy][xx] = deepcopy(ml.mlist['special'][2])#set vase monsters
  3773. self.set_monster_strength(xx,yy,player.pos[2])
  3774. if player.difficulty == 4:
  3775. self.npcs[yy][xx].AI_style = 'ignore'
  3776. monster_count += 1
  3777. if monster_count > 0:
  3778. die_mess = 'The vase shatters and '+str(monster_count)+' monsters jump out.'
  3779. else:
  3780. die_mess = 'The vase shatters.'
  3781. elif self.npcs[monster_y][monster_x].corps_style == 'mimic':
  3782. die_mess = 'The mimic wakes up.'
  3783. 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':
  3784. die_mess = 'You smash the cage!'
  3785. sfx.play('destroy_cage')
  3786. elif self.npcs[monster_y][monster_x].corps_style == 'make_blobs':
  3787. counter = 0
  3788. blob_lvl = max(self.npcs[monster_y][monster_x].lvl-1,0)
  3789. for yy in range(y-1,y+2):
  3790. for xx in range(x-1,x+2):
  3791. if yy != y or xx != x:
  3792. not_player_pos = yy != player.pos[1] or xx != player.pos[0]
  3793. if self.tilemap[yy][xx].move_group == 'soil' and not_player_pos == True and self.npcs[yy][xx] == 0:
  3794. self.npcs[yy][xx] = deepcopy(ml.mlist['special'][15])#set a green blob
  3795. self.set_monster_strength(xx,yy,player.pos[2],preset_lvl=blob_lvl)
  3796. if player.difficulty == 4:
  3797. self.npcs[yy][xx].AI_style = 'ignore'
  3798. counter += 1
  3799. if counter == 1:
  3800. die_mess = 'The giant blob leaves behind a small blob.'
  3801. elif counter > 1:
  3802. die_mess = 'The giant blob bursts into '+str(counter)+' small blobs.'
  3803. elif self.npcs[monster_y][monster_x].corps_style == 'vanish':
  3804. ran = random.randint(0,99)
  3805. if ran <= self.npcs[monster_y][monster_x].corps_lvl: #the corps_lvl determinates the chance of getting a present
  3806. real_drop = True
  3807. replace = self.tilemap[y][x]
  3808. self.tilemap[y][x] = deepcopy(tl.tlist['misc'][13])#set a present
  3809. self.tilemap[y][x].replace = replace
  3810. item_ran = random.randint(0,99)
  3811. if item_ran < 25:
  3812. items = [il.ilist['misc'][43]]#set a heavy bag
  3813. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  3814. elif item_ran < 50:
  3815. choose_ran = random.randint(0,len(il.ilist['clothe'])-1)
  3816. items = [il.ilist['clothe'][choose_ran]]
  3817. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  3818. elif item_ran < 95:
  3819. r = random.randint(3,7)
  3820. items = [il.ilist['misc'][r]]#set a workbench
  3821. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  3822. else:
  3823. items = [il.ilist['misc'][70]]#set a book of skill
  3824. self.add_container(items,x,y,deep_copy=True,checkIt=True)
  3825. ############ADD MORE HERE###############
  3826. if real_drop == True:
  3827. screen.write_hit_matrix(x,y,16)
  3828. if self.npcs[monster_y][monster_x].move_border < 10:
  3829. screen.write_hit_matrix(monster_x,monster_y,13)
  3830. if self.npcs[monster_y][monster_x].corps_style == 'mimic':
  3831. self.npcs[monster_y][monster_x] = deepcopy(ml.mlist['special'][4])#set a mimic
  3832. self.set_monster_strength(monster_x,monster_y,player.pos[2])
  3833. if player.difficulty == 4:
  3834. self.npcs[monster_y][monster_x].AI_style = 'ignore'
  3835. 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':
  3836. list_name = self.npcs[monster_y][monster_x].corps_style.replace('cage_','')
  3837. player.villager[list_name].append(self.npcs[monster_y][monster_x].corps_lvl)
  3838. self.npcs[monster_y][monster_x] = deepcopy(ml.mlist['rescued'][self.npcs[monster_y][monster_x].corps_lvl])
  3839. self.set_monster_strength(monster_x,monster_y,player.pos[2])
  3840. else:
  3841. self.npcs[monster_y][monster_x] = 0 #always del the monster if it is no mimic or cage
  3842. self.make_monsters_angry(monster_x,monster_y,'kill')
  3843. self.monster_count -= 1
  3844. if xp != None:
  3845. die_mess = die_mess + ' [+' + str(xp) + 'xp]'
  3846. message.add(die_mess)
  3847. return True
  3848. def make_shops(self):
  3849. num = int((max_map_size*max_map_size) / (50*50))
  3850. for i in range (0,num):
  3851. run = True
  3852. while run:
  3853. poses = self.find_all_moveable(False,False)
  3854. ran = random.randint(0,len(poses)-1)
  3855. pos = poses[ran]
  3856. if min(pos[0],pos[1]) > 4 and max(pos[0],pos[1]) < max_map_size-4:
  3857. run = False
  3858. x = pos[0]
  3859. y = pos[1]
  3860. for yy in range(y-2,y+3):
  3861. for xx in range(x-2,x+3):
  3862. self.npcs[yy][xx] = 0 #always del the monsters
  3863. if xx == x-2 or xx == x+2 or yy == y-2 or yy == y+2:
  3864. self.tilemap[yy][xx] = deepcopy(tl.tlist['shop'][1])
  3865. else:
  3866. self.tilemap[yy][xx] = deepcopy(tl.tlist['shop'][0])
  3867. self.tilemap[y][x-2] = deepcopy(tl.tlist['shop'][2])
  3868. self.tilemap[y][x+2] = deepcopy(tl.tlist['shop'][2])
  3869. self.tilemap[y-2][x] = deepcopy(tl.tlist['shop'][2])
  3870. self.tilemap[y+2][x] = deepcopy(tl.tlist['shop'][2])
  3871. if self.map_type == 'orcish_mines':
  3872. self.npcs[y][x] = deepcopy(ml.mlist['shop'][1])
  3873. elif self.map_type == 'grot':
  3874. self.npcs[y][x] = deepcopy(ml.mlist['shop'][2])
  3875. else:
  3876. 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
  3877. def make_monsters_angry(self,x,y,style):
  3878. for yy in range(y-3,y+4):
  3879. for xx in range(x-3,x+4):
  3880. try:
  3881. if self.npcs[yy][xx] != 0:
  3882. if self.npcs[yy][xx].anger == style:
  3883. lvl = self.npcs[yy][xx].lvl
  3884. self.npcs[yy][xx] = deepcopy(ml.mlist['angry_monster'][self.npcs[yy][xx].anger_monster])
  3885. self.set_monster_strength(xx,yy,player.pos[2],lvl)
  3886. if player.difficulty == 4:
  3887. self.npcs[yy][xx].AI_style = 'ignore'
  3888. except:
  3889. None
  3890. def time_pass(self):
  3891. #This function refresches the map for every day that past since players last visit... make plants growing etc.
  3892. if self.last_visit != time.day_total:
  3893. screen.render_load(10)
  3894. past_time = time.day_total - self.last_visit
  3895. if past_time < 0:
  3896. past_time = 364 - past_time
  3897. for c in range (0,past_time):
  3898. for y in range (0,max_map_size):
  3899. for x in range(0,max_map_size):
  3900. tile = self.tilemap[y][x]
  3901. #######Life of plants######
  3902. #1. Scrub
  3903. if tile.grow_group == 'scrub':
  3904. rand = random.randint(0,99)
  3905. if rand < 50:
  3906. replace = self.tilemap[y][x].replace
  3907. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  3908. self.tilemap[y][x].replace = replace
  3909. if tile.grow_group == 'scrub_buds':
  3910. rand = random.randint(0,99)
  3911. if rand < 90:
  3912. replace = self.tilemap[y][x].replace
  3913. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  3914. self.tilemap[y][x].replace = replace
  3915. if tile.grow_group == 'scrub_blossom':
  3916. rand = random.randint(0,99)
  3917. if rand < 80:
  3918. scrubs = random.randint(0,2)
  3919. replace = self.tilemap[y][x].replace
  3920. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[scrubs][0]][tile.conected_tiles[scrubs][1]])
  3921. self.tilemap[y][x].replace = replace
  3922. if tile.grow_group == 'scrub_berries':
  3923. rand = random.randint(0,99)
  3924. if rand < 50:
  3925. replace = self.tilemap[y][x].replace
  3926. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0][0]][tile.conected_tiles[0][1]])
  3927. self.tilemap[y][x].replace = replace
  3928. elif rand > 49 and rand < 75:
  3929. numbers =(-1,1)
  3930. for yy in numbers:
  3931. for xx in numbers:
  3932. try:
  3933. if self.tilemap[y+yy][x+xx].can_grown == True:
  3934. coin = random.randint(0,99)
  3935. if coin < 25: #25%
  3936. replace = self.tilemap[y+yy][x+xx]
  3937. self.tilemap[y+yy][x+xx] = deepcopy([tile.conected_tiles[1][0]][tile.conected_tiles[1][1]])
  3938. self.tilemap[y+yy][x+xx].replace = replace
  3939. except:
  3940. None
  3941. if tile.grow_group == 'scrub_scruffy':
  3942. rand = random.randint(0,99)
  3943. if rand < 90:
  3944. replace = self.tilemap[y][x].replace
  3945. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0][0]][tile.conected_tiles[0][1]])
  3946. self.tilemap[y][x].replace = replace
  3947. else:
  3948. replace = self.tilemap[y][x].replace
  3949. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[1][0]][tile.conected_tiles[1][1]])
  3950. self.tilemap[y][x].replace = replace
  3951. if tile.grow_group == 'scrub_grow':
  3952. rand = random.randint(0,99)
  3953. if rand < 90:
  3954. replace = self.tilemap[y][x].replace
  3955. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  3956. self.tilemap[y][x].replace = replace
  3957. #2.Tree
  3958. if tile.grow_group == 'tree_grow':
  3959. rand = random.randint(0,99)
  3960. if rand < 80 and self.npcs[y][x] == 0:
  3961. replace = self.tilemap[y][x].replace
  3962. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  3963. self.tilemap[y][x].replace = replace
  3964. if tile.grow_group == 'tree':
  3965. rand = random.randint(0,99)
  3966. if rand < 5:
  3967. replace = self.tilemap[y][x].replace
  3968. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[1][0]][tile.conected_tiles[1][1]])
  3969. self.tilemap[y][x].replace = replace
  3970. elif rand > 69:
  3971. numbers =(-2,2)
  3972. for yy in numbers:
  3973. for xx in numbers:
  3974. try:
  3975. if self.tilemap[y+yy][x+xx].can_grown == True:
  3976. coin = random.randint(0,3)
  3977. if coin == 0:
  3978. replace = self.tilemap[y+yy][x+xx]
  3979. self.tilemap[y+yy][x+xx] = deepcopy(tl.tlist[tile.conected_tiles[0][0]][tile.conected_tiles[0][1]])
  3980. self.tilemap[y+yy][x+xx].replace = replace
  3981. except:
  3982. None
  3983. #3.Herb
  3984. if tile.grow_group == 'herblike':
  3985. rand = random.randint(0,99)
  3986. if rand < 20:
  3987. replace = self.tilemap[y][x].replace
  3988. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  3989. self.tilemap[y][x].replace = replace
  3990. #4. Blue Mushrooms
  3991. if tile.grow_group == 'mushroom_mud':
  3992. rand = random.randint(0,99)
  3993. if rand < 5:
  3994. for yy in range(-1,1):
  3995. for xx in range(-1,1):
  3996. try:
  3997. if self.tilemap[y+yy][x+xx].techID == tl.tlist['misc'][1].techID:#here is mud
  3998. cent = random.randint(0,99)
  3999. if cent < 25 :
  4000. replace = self.tilemap[y+yy][x+xx]
  4001. self.tilemap[y+yy][x+xx] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  4002. self.tilemap[y+yy][x+xx].replace = replace
  4003. except:
  4004. None
  4005. #5. Brown Mushrooms
  4006. if tile.grow_group == 'mushroom_treelike':
  4007. rand = random.randint(0,99)
  4008. if rand < 5:
  4009. for yy in range(-1,1):
  4010. for xx in range(-1,1):
  4011. try:
  4012. if self.tilemap[y+yy][x+xx].techID == tl.tlist['global_caves'][0].techID:#here is cave ground
  4013. cent = random.randint(0,99)
  4014. if cent < 25 :
  4015. replace = self.tilemap[y+yy][x+xx]
  4016. self.tilemap[y+yy][x+xx] = deepcopy(tl.tlist[tile.conected_tiles[0][0]][tile.conected_tiles[0][1]])
  4017. self.tilemap[y+yy][x+xx].replace = replace
  4018. except:
  4019. None
  4020. elif rand < 30:#make a giant mushroom
  4021. replace = self.tilemap[y][x].replace
  4022. self.tilemap[y][x] = deepcopy(tl.tlist[tile.conected_tiles[1][0]][tile.conected_tiles[1][1]])
  4023. self.tilemap[y][x].replace = replace
  4024. #6. Purple Mushrooms
  4025. if tile.grow_group == 'mushroom': #let grow new mushrooms and let the old ones die(5%)
  4026. rand = random.randint(0,99)
  4027. if rand < 5:
  4028. for yy in range(-1,1):
  4029. for xx in range(-1,1):
  4030. try:
  4031. if self.tilemap[y+yy][x+xx].techID == tl.tlist['global_caves'][0].techID:#here is cave ground
  4032. cent = random.randint(0,99)
  4033. if cent < 25 :
  4034. replace = self.tilemap[y+yy][x+xx]
  4035. self.tilemap[y+yy][x+xx] = deepcopy(tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]])
  4036. self.tilemap[y+yy][x+xx].replace = replace
  4037. except:
  4038. None
  4039. #7. Agriculture
  4040. if tile.grow_group == 'agri0':
  4041. rand = random.randint(0,99)
  4042. if rand < 50:
  4043. if self.map_type == 'overworld':
  4044. self.tilemap[y][x] = tl.tlist[tile.conected_tiles[0][0]][tile.conected_tiles[0][1]]
  4045. elif self.map_type == 'cave' or self.map_type == 'desert_cave':
  4046. self.tilemap[y][x] = tl.tlist[tile.conected_tiles[1][0]][tile.conected_tiles[1][1]]
  4047. elif self.map_type == 'desert':
  4048. self.tilemap[y][x] = tl.tlist[tile.conected_tiles[2][0]][tile.conected_tiles[2][1]]
  4049. if tile.grow_group == 'agri1': #let something grow on a acriculture (final, at the overworld) (50%)
  4050. rand = random.randint(0,99)
  4051. if rand < 50:
  4052. self.tilemap[y][x] = tl.tlist[tile.conected_tiles[0]][tile.conected_tiles[1]]
  4053. #8. Vanish
  4054. if tile.grow_group == 'vanish':
  4055. rand = random.randint(0,99)
  4056. if rand < 50:
  4057. self.tilemap[y][x] = self.tilemap[y][x].replace
  4058. self.containers[y][x] = 0
  4059. #9. Magic shops
  4060. if tile.techID == tl.tlist['shop'][4].techID and player.on_map != 'shop_0_0':
  4061. self.tilemap[y][x] = self.tilemap[y][x].replace
  4062. #######Misc#######
  4063. #0. Rubble
  4064. if tile.techID == tl.tlist['functional'][26].techID:
  4065. rand = random.randint(0,99)
  4066. if rand < 20:
  4067. count_rubble = 0
  4068. count_sand = 0
  4069. count_grass = 0
  4070. count_cave = 0
  4071. for yy in range(y-1,y+2):
  4072. for xx in range(x-1,x+2):
  4073. if self.tilemap[yy][xx].techID == tl.tlist['functional'][26]:#this is rubble
  4074. count_rubble += 1
  4075. elif self.tilemap[yy][xx].techID == tl.tlist['local'][0]:#this is grass
  4076. count_grass += 1
  4077. elif self.tilemap[yy][xx].techID == tl.tlist['extra'][0]:#this is sand
  4078. count_sand += 1
  4079. elif self.tilemap[yy][xx].techID == tl.tlist['global_caves'][0]:#this is cave
  4080. count_cave +=1
  4081. if count_rubble < 8: #this tile isnt surrounded by rubble
  4082. if count_cave > 1:
  4083. self.tilemap[y][x] = deepcopy(tl.tlist['global_caves'][0])
  4084. elif count_grass >= count_sand:
  4085. self.tilemap[y][x] = deepcopy(tl.tlist['local'][0])
  4086. else:
  4087. self.tilemap[y][x] = deepcopy(tl.tlist['extra'][0])
  4088. #########add other events for growing plants etc here########
  4089. 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
  4090. for i in range(0,len(player.inventory.food)):#let the food rot in the players inventory
  4091. if player.inventory.food[i] != player.inventory.nothing:
  4092. player.inventory.food[i].rot()
  4093. if player.on_map != 'shop_0_0':
  4094. shop_num = int((max_map_size**2)/(50**2))
  4095. self.spawn_magic_shops(shop_num)
  4096. screen.render_load(5)
  4097. save(world,player,time,gods,save_path,os.sep)
  4098. def exchange(self,old_tile,new_tile,use_deepcopy=False):
  4099. for y in range (0,max_map_size):
  4100. for x in range (0,max_map_size):
  4101. if self.tilemap[y][x].techID == old_tile.techID:
  4102. if use_deepcopy == False:
  4103. self.tilemap[y][x] = new_tile
  4104. else:
  4105. self.tilemap[y][x] = deepcopy(new_tile)
  4106. def find_first(self,tile):
  4107. for y in range (0,max_map_size):
  4108. for x in range (0,max_map_size):
  4109. if self.tilemap[y][x].techID == tile.techID:
  4110. return [x,y]
  4111. if self.tilemap[y][x].name == tile.name:#fallback
  4112. return [x,y] #
  4113. return False
  4114. def find_any(self,tile):
  4115. found = []
  4116. for y in range(0,max_map_size):
  4117. for x in range(0,max_map_size):
  4118. if self.tilemap[y][x].techID == tile.techID and self.npcs[y][x] == 0:
  4119. found.append((x,y))
  4120. if found == []:
  4121. return False
  4122. elif len(found) == 1:
  4123. return found[0]
  4124. else:
  4125. ran = random.randint(0,len(found)-1)
  4126. return found[ran]
  4127. def find_all_moveable(self,ignore_water = True,ignore_player_pos = False, ignore_no_spawn = True):
  4128. cordinates_list = []
  4129. for y in range (0, max_map_size):
  4130. for x in range (0,max_map_size):
  4131. moveable = False
  4132. if ignore_water == True:
  4133. if self.tilemap[y][x].move_group == 'soil':
  4134. moveable = True
  4135. else:
  4136. if self.tilemap[y][x].move_group == 'soil' or self.tilemap[y][x].move_group == 'low_liquid':
  4137. moveable = True
  4138. if ignore_player_pos == True:
  4139. player_pos_check = False
  4140. else:
  4141. if (x - entrance_x < -7) or (y - entrance_y < -7) or (x - entrance_x > 7) or (y - entrance_y > 7):
  4142. player_pos_check = False
  4143. else:
  4144. player_pos_check = True
  4145. spawn_check = True
  4146. if ignore_no_spawn == False:
  4147. if self.tilemap[y][x].no_spawn == True:
  4148. spawn_check = False
  4149. 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:
  4150. cordinates_list.append((x,y))
  4151. if len(cordinates_list) > 0:
  4152. return cordinates_list
  4153. else:
  4154. return False
  4155. def add_container(self, inventory, x, y, deep_copy = True, checkIt = False):
  4156. self.containers[y][x] = container(inventory,deep_copy)
  4157. if checkIt == True:
  4158. if self.check_container(x,y) != True:
  4159. print('Container creation failed!')
  4160. self.containers[y][x] = 0
  4161. self.tilemap[y][x] = self.tilemap[y][x].replace
  4162. def check_container(self,x,y):
  4163. if self.tilemap[y][x].replace != None and len(self.containers[y][x].items) > 0:
  4164. return True
  4165. else:
  4166. return False
  4167. def special_check(self,x,y):
  4168. sfx_flame = False
  4169. sfx_vapor = False
  4170. for yy in range(y-7,y+8):
  4171. for xx in range(x-7,x+8):
  4172. try:
  4173. if (self.tilemap[yy][xx].special_group == 'flamable' or self.tilemap[yy][xx].special_group == 'highly flamable') and self.tilemap[yy][xx].replace != None:
  4174. heat_source = 0
  4175. for yyy in range(yy-1,yy+2):
  4176. for xxx in range(xx-1,xx+2):
  4177. try:
  4178. if self.tilemap[yyy][xxx].special_group == 'hot':
  4179. heat_source += 1
  4180. except:
  4181. None
  4182. if heat_source > 0:
  4183. if self.tilemap[yy][xx].special_group == 'flamable':
  4184. ran = random.randint(0,9)
  4185. else:
  4186. ran = 9
  4187. if ran > 5:
  4188. sfx_flame = True
  4189. self.containers[yy][xx] = 0
  4190. if world.maplist[player.pos[2]][player.on_map].npcs[yy][xx] != 0:
  4191. if world.maplist[player.pos[2]][player.on_map].npcs[yy][xx].techID == ml.mlist['special'][14].techID: #this is a demonic chest
  4192. world.maplist[player.pos[2]][player.on_map].monster_die(xx,yy)
  4193. self.countdowns.append(countdown('flame',xx,yy,self.tilemap[yy][xx].special_num))
  4194. replace = self.tilemap[yy][xx].replace
  4195. self.tilemap[yy][xx] = deepcopy(tl.tlist['effect'][4])
  4196. self.tilemap[yy][xx].replace = replace
  4197. elif self.tilemap[yy][xx].special_group == 'explosive' or self.tilemap[yy][xx].special_group == 'highly explosive':
  4198. heat_sources = 0
  4199. for yyy in range(yy-1,yy+2):
  4200. for xxx in range(xx-1,xx+2):
  4201. try:
  4202. if self.tilemap[yyy][xxx].special_group == 'hot':
  4203. heat_sources += 1
  4204. except:
  4205. None
  4206. if heat_sources > 0:
  4207. if self.tilemap[yyy][xxx].special_group == 'explosive':
  4208. ran = random.randint(0,9)
  4209. else:
  4210. ran = 9
  4211. if ran > 5:
  4212. self.countdowns.append(countdown('bomb1',xx,yy,1))
  4213. for yyy in range(yy-1,yy+2):
  4214. for xxx in range(xx-1,xx+2):
  4215. try:
  4216. if self.tilemap[yyy][xxx].special_group == 'explosive' or elf.tilemap[yyy][xxx].special_group == 'highly explosive':
  4217. self.countdowns.append(countdown('bomb1',xxx,yyy,1))
  4218. except:
  4219. None
  4220. elif self.tilemap[yy][xx].special_group == 'vaporable':
  4221. heat_sources = 0
  4222. for yyy in range(yy-1,yy+2):
  4223. for xxx in range(xx-1,xx+2):
  4224. try:
  4225. if self.tilemap[yyy][xxx].special_group == 'hot':
  4226. heat_sources += 1
  4227. except:
  4228. None
  4229. if heat_sources >= self.tilemap[yy][xx].special_num:
  4230. sfx.vapor = True
  4231. self.tilemap[yy][xx] = deepcopy(tl.tlist['misc'][1])#mud
  4232. except:
  4233. None
  4234. if sfx_flame == True:
  4235. sfx.play('flame')
  4236. if sfx_vapor == True:
  4237. sfx.play('steam')
  4238. def spawn_monster_groups(self,leader,follower,max_group_size):
  4239. for y in range(0,max_map_size):
  4240. for x in range(0,max_map_size):
  4241. if self.npcs[y][x] != 0 and self.npcs[y][x].techID == leader.techID:
  4242. m_count = 1
  4243. for yy in range(y-1,y+2):
  4244. for xx in range(x-1,x+2):
  4245. if m_count < max_group_size and self.npcs[yy][xx] == 0 and self.tilemap[yy][xx].move_group in follower.move_groups:
  4246. self.npcs[yy][xx] = deepcopy(follower)
  4247. self.set_monster_strength(xx,yy,max(self.npcs[y][x].lvl-5,1))
  4248. if player.difficulty == 4:
  4249. self.npcs[yy][xx].AI_style = 'ignore'
  4250. m_count += 1
  4251. def make_special_monsters(self, min_no, max_no, on_tile, depth, monster_type='vase'):
  4252. size = int((max_map_size*max_map_size)/(50*50))
  4253. for i in range(0,size):
  4254. num_monster = random.randint(min_no,max_no)
  4255. if num_monster > 0:
  4256. for z in range (0,num_monster):
  4257. pos = self.find_any(on_tile)
  4258. if monster_type == 'vase':
  4259. ran = random.randint(0,99)
  4260. if ran < 10:
  4261. self.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['special'][1]) #spawn a monster vase
  4262. self.npcs[pos[1]][pos[0]].attribute = attribute(0,0,0,0,0,1,0)
  4263. else:
  4264. self.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['special'][0]) #spawn a vase
  4265. self.npcs[pos[1]][pos[0]].attribute = attribute(0,0,0,0,0,1,0)
  4266. elif monster_type == 'mimic':
  4267. pos = self.find_any(on_tile)
  4268. self.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['special'][3]) #spawn a sleeping mimic
  4269. self.npcs[pos[1]][pos[0]].attribute = attribute(0,0,0,0,0,1,0)
  4270. elif monster_type == 'demonic chest':
  4271. pos = self.find_any(on_tile)
  4272. self.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['functional'][4])#cest
  4273. self.tilemap[pos[1]][pos[0]].replace = deepcopy(on_tile)
  4274. 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])
  4275. ran1 = random.randint(0,len(sb)-1)
  4276. ran2 = random.randint(0,len(sb)-1)
  4277. items = [sb[ran1],sb[ran2]]
  4278. self.containers[pos[1]][pos[0]] = container(items,True)
  4279. self.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['special'][14])
  4280. self.set_monster_strength(pos[0],pos[1],depth)
  4281. #set monsters personal_id
  4282. 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))
  4283. def make_containers(self, min_no, max_no, on_tile, item_min, item_max, container_type='remains'):
  4284. size = int((max_map_size*max_map_size)/(50*50))
  4285. for i in range(0,size):
  4286. num_container = random.randint(min_no,max_no)
  4287. if num_container > 0:
  4288. for z in range (0,num_container):
  4289. c_type = container_type
  4290. if c_type == 'chest':
  4291. ch = random.randint(0,99)
  4292. if ch < 5:
  4293. c_type = 'fridge'
  4294. place = self.find_any(on_tile)
  4295. inventory = []
  4296. num_items = random.randint(item_min,item_max)##############item_min,item_max
  4297. for t in range (0,num_items):
  4298. if c_type == 'chest':
  4299. coin = random.randint(0,1)
  4300. if coin == 0:#add equipmen
  4301. classes = ['sword', 'axe', 'hammer', 'spear', 'helmet', 'armor', 'cuisse', 'shoes', 'wand', 'rune', 'rune staff', 'artefact', 'amulet', 'ring', 'talisman', 'necklace', 'pickaxe']
  4302. class_num = random.randint(0,len(classes)-1)
  4303. material = random.randint(0,20)
  4304. plus = random.randint(-3,3)
  4305. state = random.randint(80,100)
  4306. curse_chance = random.randint(0,30)
  4307. if curse_chance < material:
  4308. curse = 0
  4309. elif curse_chance == material:
  4310. curse = 2
  4311. else:
  4312. curse = 1
  4313. item = item_wear(classes[class_num], material, plus, state, curse, False)
  4314. inventory.append(item)
  4315. elif coin == 1:
  4316. items = []
  4317. for i in range(14,21):
  4318. items.append(il.ilist['misc'][i])
  4319. for i in range(22,40):
  4320. items.append(il.ilist['misc'][i])
  4321. for i in range(44,47):
  4322. items.append(il.ilist['misc'][i])
  4323. for j in range(6,9):
  4324. items.append(il.ilist['food'][j])
  4325. for j in range(13,25):
  4326. items.append(il.ilist['food'][j])
  4327. for j in range(29,32):
  4328. items.append(il.ilist['food'][j])
  4329. ran = random.randint(0,len(items)-1)
  4330. inventory.append(deepcopy(items[ran]))
  4331. elif c_type == 'remains':
  4332. classes = ['sword', 'axe', 'hammer', 'spear', 'helmet', 'armor', 'cuisse', 'shoes', 'wand', 'rune', 'rune staff', 'artefact', 'amulet', 'ring', 'talisman', 'necklace', 'pickaxe']
  4333. class_num = random.randint(0,len(classes)-1)
  4334. material = random.randint(0,20)
  4335. plus = random.randint(-3,3)
  4336. state = random.randint(20,60)
  4337. curses = (0,1,2)
  4338. curse_num = random.randint(0,2)
  4339. item = item_wear(classes[class_num], material, plus, state, curses[curse_num], False)
  4340. inventory.append(item)
  4341. elif c_type == 'fridge':
  4342. ran = random.randint(0,len(il.ilist['food'])-1)
  4343. inventory.append(deepcopy(il.ilist['food'][ran]))
  4344. if c_type == 'chest':
  4345. self.add_container(inventory, place[0], place[1])
  4346. replace = self.tilemap[place[1]][place[0]]
  4347. self.tilemap[place[1]][place[0]] = deepcopy(tl.tlist['functional'][4])#chest
  4348. self.tilemap[place[1]][place[0]].replace = replace
  4349. elif c_type == 'remains':
  4350. replace_tile = self.tilemap[place[1]][place[0]]
  4351. self.add_container(inventory, place[0], place[1])
  4352. self.tilemap[place[1]][place[0]] = deepcopy(tl.tlist['functional'][6])#remains
  4353. self.tilemap[place[1]][place[0]].replace = replace_tile
  4354. elif c_type == 'fridge':
  4355. replace_tile = self.tilemap[place[1]][place[0]]
  4356. self.add_container(inventory, place[0], place[1])
  4357. self.tilemap[place[1]][place[0]] = deepcopy(tl.tlist['functional'][25])#fridge
  4358. self.tilemap[place[1]][place[0]].replace = replace_tile
  4359. def exchange_when_surrounded(self, tile_check, tile_replace, number_neighbors):
  4360. #check all cordinates for their neighbors(including them self) and exchange th tile when the number of neighbors with the same techID => number_neighbors
  4361. for y in range (0,max_map_size):
  4362. for x in range (0,max_map_size):
  4363. count = 0
  4364. for yy in range (-1,2):
  4365. for xx in range (-1,2):
  4366. try:
  4367. if self.tilemap[y+yy][x+xx].techID == tile_check.techID or self.tilemap[y+yy][x+xx].techID == tile_replace.techID:
  4368. count += 1
  4369. except:
  4370. None
  4371. if count >= number_neighbors:
  4372. self.tilemap[y][x] = tile_replace
  4373. def sget(self):
  4374. string = ''
  4375. for c in range (0,max_map_size):
  4376. for d in range (0,max_map_size):
  4377. if d != player.pos[0] or c != player.pos[1]:
  4378. if self.known[c][d] != 0:
  4379. string = string + self.tilemap[c][d].char
  4380. else:
  4381. string += '\033[0;30;40m '
  4382. else:
  4383. string = string + player.char
  4384. string = string + '\n'
  4385. return string
  4386. def spawn_magic_shops(self,num=1):
  4387. if self.name == 'shop_0_0':
  4388. return False
  4389. pos = []
  4390. for i in range(0,num):
  4391. for y in range(0,max_map_size):
  4392. for x in range(0,max_map_size):
  4393. if self.tilemap[y][x].move_group == 'solid':
  4394. num_soil = 0
  4395. try:
  4396. if self.tilemap[y-1][x].move_group == 'soil':
  4397. num_soil += 1
  4398. except:
  4399. None
  4400. try:
  4401. if self.tilemap[y+1][x].move_group == 'soil':
  4402. num_soil += 1
  4403. except:
  4404. None
  4405. try:
  4406. if self.tilemap[y][x-1].move_group == 'soil':
  4407. num_soil += 1
  4408. except:
  4409. None
  4410. try:
  4411. if self.tilemap[y][x+1].move_group == 'soil':
  4412. num_soil += 1
  4413. except:
  4414. None
  4415. if num_soil > 0:
  4416. pos.append((x,y))
  4417. if len(pos) < 1:
  4418. return False
  4419. ran = random.randint(0,len(pos)-1)
  4420. replace = deepcopy(self.tilemap[pos[ran][1]][pos[ran][0]])
  4421. self.tilemap[pos[ran][1]][pos[ran][0]] = deepcopy(tl.tlist['shop'][4])
  4422. self.tilemap[pos[ran][1]][pos[ran][0]].replace = replace
  4423. #print('Shop at: '+str(pos[ran][0])+','+str(pos[ran][1]))
  4424. def set_sanctuary(self,startx,starty):
  4425. for y in range (starty-2, starty+3):
  4426. for x in range (startx-2, startx+3):
  4427. self.tilemap[y][x] = deepcopy(tl.tlist['sanctuary'][0])#sanctuary floor
  4428. if x == startx-2 or x == startx or x == startx+2:
  4429. if y == starty-2 or y == starty or y == starty+2:
  4430. self.tilemap[y][x] = deepcopy(tl.tlist['sanctuary'][1])#sanctuary pilar
  4431. self.tilemap[starty][startx] = deepcopy(tl.tlist['sanctuary'][2])#sanctuary spawn point
  4432. self.tilemap[starty-1][startx] = deepcopy(tl.tlist['functional'][20])#divine gift
  4433. self.tilemap[starty-1][startx].replace = tl.tlist['sanctuary'][0]
  4434. self.countdowns.append(countdown('gift_to_workbench',startx,starty-1,1))
  4435. material_pick = random.randint(0,10)
  4436. material_axe = random.randint(0,10)
  4437. material_amo = random.randint(0,10)
  4438. amo_classes = ('shoes','cuisse','armor','helmet')
  4439. ran = random.randint(0,3)
  4440. amo_class = amo_classes[ran]
  4441. pick = item_wear('pickaxe', material_pick,0)
  4442. axe = item_wear('axe',material_axe,0)
  4443. amo = item_wear(amo_class,material_amo,0)
  4444. ran_tunica = random.randint(0,2)
  4445. #original
  4446. 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)
  4447. #/original
  4448. # statue demo:
  4449. #list_t = [pick,axe]
  4450. #for f in range(55,70):
  4451. # list_t.append(il.ilist['misc'][f])
  4452. #self.add_container(list_t,startx,starty-1)
  4453. # 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)
  4454. # 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)
  4455. # 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)
  4456. self.tilemap[starty+1][startx] = deepcopy(tl.tlist['functional'][1])#stair down
  4457. self.tilemap[starty+1][startx].damage = -1
  4458. self.tilemap[starty+1][startx].damage_mes = 'Your wounds are cured.'
  4459. self.tilemap[starty+1][startx].build_here = False
  4460. self.tilemap[starty+1][startx].move_group = 'holy'
  4461. class world_class():
  4462. def __init__(self,tilelist):
  4463. global max_map_size
  4464. screen.render_load(0)
  4465. name = save_path + os.sep + 'world.data'
  4466. self.map_size = 52
  4467. self.startx = 0
  4468. self.starty = 0
  4469. try:
  4470. f = open(name, 'rb')
  4471. temp = p.load(f)
  4472. screen.render_load(1)
  4473. self.maplist = temp.maplist
  4474. self.map_size = temp.map_size
  4475. max_map_size = self.map_size
  4476. self.startx = temp.startx
  4477. self.starty = temp.starty
  4478. except:
  4479. screen.render_load(2)
  4480. self.maplist = []
  4481. for x in range (0,7):
  4482. self.maplist.append({})
  4483. screen.render_load(3)
  4484. pos = self.grassland_generator(0,0,30,80,5,int((max_map_size*max_map_size)/20))
  4485. self.startx = pos[0]
  4486. self.starty = pos[1]
  4487. self.cave_generator(4)
  4488. self.border_generator(6)
  4489. screen.render_load(5)
  4490. self.elysium_generator()
  4491. def default_map_generator(self, name, tiles, tilelist): #check if tilelist can be deleted
  4492. tilemap = []
  4493. for i in range (0,max_map_size):
  4494. tilemap.append([])
  4495. a = 0
  4496. for b in range (0,max_map_size):
  4497. ran_num = random.randint(0,len(tl.tlist[tiles])-1)
  4498. tilemap[a].append(tl.tlist[tiles][ran_num])
  4499. b = 0
  4500. for a in range (1,max_map_size):
  4501. ran_num = random.randint(0,len(tl.tlist[tiles])-1)
  4502. tilemap[a].append(tl.tlist[tiles][ran_num])
  4503. for a in range (1,max_map_size):
  4504. for b in range (1,max_map_size):
  4505. ran_same = random.randint(0,9)
  4506. if ran_same < 5 :
  4507. tilemap[a].append(tilemap[a-1][b])
  4508. elif ran_same < 8:
  4509. tilemap[a].append(tilemap[a][b-1])
  4510. else:
  4511. ran_num = random.randint(0,len(tl.tlist[tiles])-1)
  4512. tilemap[a].append(tl.tlist[tiles][ran_num])
  4513. m = maP(name ,tilemap)
  4514. return m
  4515. def border_generator(self,layer,style='default'):
  4516. if style == 'default':
  4517. cave_name = 'local_0_0'
  4518. elif style == 'desert':
  4519. cave_name = 'desert_0_0'
  4520. m = self.default_map_generator(cave_name,'global_caves', tilelist)
  4521. m.map_type = 'border'
  4522. m.fill(tl.tlist['functional'][0])#fill with border
  4523. self.maplist[layer][cave_name] = m
  4524. def grot_generator(self,layer):
  4525. screen.render_load(15,1)
  4526. cave_name = 'dungeon_0_0'
  4527. m = self.default_map_generator(cave_name,'global_caves', tilelist)
  4528. m.map_type = 'grot'
  4529. m.set_music('grot','grot',True)
  4530. m.build_type = 'None'
  4531. m.fill(tl.tlist['global_caves'][3])#fill with hard rock
  4532. 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
  4533. m.set_frame(tl.tlist['functional'][0])
  4534. chance_ore = layer*5
  4535. chance_gem = layer*3
  4536. screen.render_load(15,10)
  4537. for y in range (0,max_map_size):
  4538. for x in range (0,max_map_size):
  4539. if m.tilemap[y][x].techID == tl.tlist['global_caves'][3].techID:#this is hard rock
  4540. replace = m.tilemap[y][x].replace
  4541. coin = random.randint(0,1)
  4542. percent = random.randint(1,100)
  4543. if coin == 0 and percent <= chance_ore:
  4544. m.tilemap[y][x] = tl.tlist['misc'][4]#set ore here
  4545. m.tilemap[y][x].replace = replace
  4546. elif coin == 1 and percent <= chance_gem:
  4547. m.tilemap[y][x] = tl.tlist['misc'][5]#set gem here
  4548. m.tilemap[y][x].replace = replace
  4549. screen.render_load(15,40)
  4550. for y in range (0,max_map_size):
  4551. for x in range (0,max_map_size):
  4552. if m.tilemap[y][x].techID == tl.tlist['misc'][1].techID:#this is mud
  4553. cent = random.randint(0,99)
  4554. if cent < 10: #its a chance of 10% that a blue mushroom spawns here
  4555. replace = m.tilemap[y][x]
  4556. m.tilemap[y][x] = tl.tlist['misc'][6]
  4557. m.tilemap[y][x].replace = replace
  4558. m.containers[y][x] = container([deepcopy(il.ilist['food'][1])])
  4559. screen.render_load(15,75)
  4560. num_lilys = int(((max_map_size*max_map_size)/100)*3)
  4561. for i in range (0,num_lilys):
  4562. pos = m.find_any(tl.tlist['misc'][0])#find low wather
  4563. try:
  4564. coin = random.randint(0,1)
  4565. if coin == 0:
  4566. m.tilemap[pos[1]][pos[0]] = tl.tlist['misc'][10]#set a water lily
  4567. else:
  4568. m.tilemap[pos[1]][pos[0]] = tl.tlist['misc'][14]#set a water lily with blossom
  4569. except:
  4570. None
  4571. screen.render_load(15,90)
  4572. pos = m.find_any(tl.tlist['misc'][0])#find any low water tile
  4573. m.tilemap[pos[1]][pos[0]] = tl.tlist['dungeon'][15]#set stair up
  4574. entrance_x = pos[0]
  4575. entrance_y = pos[1]
  4576. for sy in range(pos[1]-4,pos[1]+5):
  4577. for sx in range(pos[0]-4,pos[0]+5):
  4578. try:
  4579. if m.tilemap[sy][sx].move_group == 'soil':
  4580. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  4581. m.tilemap[sy][sx].move_group == 'dry_entrance'
  4582. elif m.tilemap[sy][sx].move_group == 'low_liquid':
  4583. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  4584. m.tilemap[sy][sx].move_group == 'wet_entrance'
  4585. except:
  4586. None
  4587. m.make_shops()
  4588. m.spawn_monsters(3)
  4589. screen.render_load(15,99)
  4590. self.maplist[layer][cave_name] = m
  4591. def elfish_generator(self,layer):
  4592. screen.render_load(16,1)
  4593. map_name = 'fortress_0_0'
  4594. m = self.default_map_generator(map_name,'global_caves', tilelist)
  4595. m.map_type = 'elfish_fortress'
  4596. m.set_music('elfish_fortress','elfish_fortress',True)
  4597. m.no_monster_respawn = True
  4598. m.build_type = 'None'
  4599. m.fill(tl.tlist['elfish'][0])
  4600. for y in range (10, max_map_size-10,10):
  4601. ran = random.randint(0,3)
  4602. for yy in range (y-1,y+2):
  4603. if ran < 3:
  4604. m.imp_connect((0,max_map_size-1),(yy,yy),tl.tlist['elfish'][1],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  4605. if ran < 3:
  4606. m.imp_connect((0,max_map_size-1),(y-2,y-2),tl.tlist['elfish'][3],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  4607. m.imp_connect((0,max_map_size-1),(y+2,y+2),tl.tlist['elfish'][3],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  4608. screen.render_load(16,10)
  4609. for x in range (10, max_map_size-10,10):
  4610. ran = random.randint(0,3)
  4611. for xx in range (x-1,x+2):
  4612. if ran < 3:
  4613. m.imp_connect((xx,xx),(0,max_map_size-1),tl.tlist['elfish'][1],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  4614. if ran < 3:
  4615. m.imp_connect((x-2,x-2),(0,max_map_size-1),tl.tlist['elfish'][3],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  4616. m.imp_connect((x+2,x+2),(0,max_map_size-1),tl.tlist['elfish'][3],tl.tlist['elfish'][1],tl.tlist['elfish'][1])
  4617. m.cut(5,max_map_size-6,5,max_map_size-6,tl.tlist['elfish'][3])
  4618. building_count = 0
  4619. run = True
  4620. screen.render_load(16,30)
  4621. while run:
  4622. pos=m.find_first(tl.tlist['elfish'][0])
  4623. if pos != False:
  4624. m.floating(pos[0],pos[1],tl.tlist['elfish'][5],tl.tlist['elfish'][3])#fill with help passive
  4625. building_count += 1
  4626. else:
  4627. run = False
  4628. m.exchange(tl.tlist['elfish'][5],tl.tlist['elfish'][0])
  4629. screen.render_load(16,50)
  4630. if building_count < 6:
  4631. return False #return false to make a loop if there are to less buildings inside the map
  4632. num_temples = int((float(building_count)/100)*10)
  4633. if num_temples == 0:
  4634. num_temples = 1
  4635. num_agriculture = int((float(building_count)/100)*10)
  4636. if num_agriculture == 0:
  4637. num_agriculture=1
  4638. num_meetingarea = int((float(building_count)/100)*10)
  4639. if num_meetingarea == 0:
  4640. num_meetingarea = 1
  4641. num_marketplace = int((float(building_count)/100)*10)
  4642. if num_marketplace == 0:
  4643. num_marketplace = 1
  4644. num_libaries = int((float(building_count)/100)*10)
  4645. if num_libaries == 0:
  4646. num_libaries = 1
  4647. num_dwellings = building_count-num_temples-num_agriculture-num_meetingarea-num_marketplace-num_libaries
  4648. screen.render_load(16,60)
  4649. m.cut(5,max_map_size-6,5,max_map_size-6,tl.tlist['elfish'][1])
  4650. for i in range(0,num_agriculture):
  4651. pos = m.find_any(tl.tlist['elfish'][0])#find any elfish_floor_indoor
  4652. m.floating(pos[0],pos[1],tl.tlist['elfish'][2],tl.tlist['elfish'][1])#replace this building with elfish_agriculture
  4653. for y in range(0,max_map_size,2):
  4654. for x in range(0,max_map_size):
  4655. if m.tilemap[y][x].techID == tl.tlist['elfish'][2].techID:#this is elfish agriculture
  4656. m.tilemap[y][x] = tl.tlist['misc'][0]#set low water
  4657. screen.render_load(16,65)
  4658. m.cut(5,max_map_size-6,5,max_map_size-6,tl.tlist['elfish'][3])
  4659. for i in range(0,num_marketplace):#set marketplaces
  4660. pos = m.find_any(tl.tlist['elfish'][0])#find any elfish_floor_indoor
  4661. m.floating(pos[0],pos[1],tl.tlist['elfish'][4],tl.tlist['elfish'][3])#fill this building with elfish_active
  4662. pos = m.find_first(tl.tlist['elfish'][4])
  4663. size = m.get_quarter_size(pos[0],pos[1])
  4664. for y in range(pos[1]+1,pos[1]+size[1]-1,2):
  4665. for x in range(pos[0]+1,pos[0]+size[0]-1,3):
  4666. m.npcs[y][x] = ml.mlist['shop'][0]
  4667. m.exchange(tl.tlist['elfish'][4],tl.tlist['shop'][0])
  4668. screen.render_load(16,70)
  4669. for i in range(0,num_temples):
  4670. pos = m.find_any(tl.tlist['elfish'][0])#find any elfish_floor_indoor
  4671. m.floating(pos[0],pos[1],tl.tlist['elfish'][4],tl.tlist['elfish'][3])#fill this building with elfish_active
  4672. pos = m.find_first(tl.tlist['elfish'][4])
  4673. size = m.get_quarter_size(pos[0],pos[1])
  4674. for y in range(pos[1],pos[1]+size[1],2):
  4675. for x in range(pos[0],pos[0]+size[0],2):
  4676. m.tilemap[y][x] = deepcopy(tl.tlist['functional'][22])
  4677. m.tilemap[y][x].replace = tl.tlist['elfish'][0]
  4678. m.tilemap[y][x].civilisation = False
  4679. m.tilemap[pos[1]+int(size[1]/2)][pos[0]+int(size[0]/2)] = deepcopy(tl.tlist['functional'][15])#set a altar
  4680. m.tilemap[pos[1]+int(size[1]/2)][pos[0]+int(size[0]/2)].replace = tl.tlist['elfish'][0]
  4681. m.tilemap[pos[1]+int(size[1]/2)][pos[0]+int(size[0]/2)].civilisation = False
  4682. m.exchange(tl.tlist['elfish'][4],tl.tlist['elfish'][5])
  4683. screen.render_load(16,75)
  4684. for i in range(0,num_meetingarea):
  4685. pos = m.find_any(tl.tlist['elfish'][0])
  4686. m.floating(pos[0],pos[1],tl.tlist['elfish'][4],tl.tlist['elfish'][3])#fill this building with elfish_active
  4687. pos = m.find_first(tl.tlist['elfish'][4])
  4688. size = m.get_quarter_size(pos[0],pos[1])
  4689. for y in range(pos[1]+2,pos[1]+size[1]-2):
  4690. for x in range(pos[0]+2,pos[0]+size[0]-1,4):
  4691. m.tilemap[y][x] = deepcopy(tl.tlist['functional'][16]) #set table
  4692. m.tilemap[y][x].replace = tl.tlist['elfish'][0]
  4693. m.tilemap[y][x].civilisation = False
  4694. for xx in range(x-1,x+2):
  4695. if m.tilemap[y][xx].techID == tl.tlist['elfish'][4].techID:
  4696. m.tilemap[y][xx] = deepcopy(tl.tlist['functional'][18])
  4697. m.tilemap[y][xx].replace = tl.tlist['elfish'][0]
  4698. m.tilemap[y][xx].civilisation = False
  4699. for yy in range(y-1,y+2):
  4700. if m.tilemap[yy][x].techID == tl.tlist['elfish'][4].techID:
  4701. m.tilemap[yy][x] = deepcopy(tl.tlist['functional'][18])
  4702. m.tilemap[yy][x].replace = tl.tlist['elfish'][0]
  4703. m.tilemap[yy][x].civilisation = False
  4704. m.exchange(tl.tlist['elfish'][4],tl.tlist['elfish'][5])
  4705. screen.render_load(16,80)
  4706. for i in range(0,num_libaries):
  4707. pos = m.find_any(tl.tlist['elfish'][0])
  4708. m.floating(pos[0],pos[1],tl.tlist['elfish'][4],tl.tlist['elfish'][3])#fill this building with elfish_active
  4709. pos = m.find_first(tl.tlist['elfish'][4])
  4710. size = m.get_quarter_size(pos[0],pos[1])
  4711. for y in range(pos[1]+1,pos[1]+size[1]-1,2):
  4712. for x in range(pos[0]+1,pos[0]+size[0]-1,2):
  4713. m.tilemap[y][x] = deepcopy(tl.tlist['functional'][19])
  4714. m.tilemap[y][x].civilisation = False
  4715. m.exchange(tl.tlist['elfish'][4],tl.tlist['elfish'][5])
  4716. screen.render_load(16,85)
  4717. for i in range(0,num_dwellings):
  4718. pos = m.find_any(tl.tlist['elfish'][0])
  4719. m.floating(pos[0],pos[1],tl.tlist['elfish'][4],tl.tlist['elfish'][3])#fill this building with elfish_active
  4720. pos = m.find_first(tl.tlist['elfish'][4])
  4721. pos_original = pos
  4722. size = m.get_quarter_size(pos[0],pos[1])
  4723. num_beds = int((size[0]*size[1])/9)
  4724. num_furniture = int((size[0]*size[1])/25)
  4725. for y in range(pos[1],pos[1]+size[1]):
  4726. for x in range(pos[0],pos[0]+size[0]):
  4727. m.tilemap[y][x] = tl.tlist['elfish'][5]
  4728. for y in range(pos[1]+1,pos[1]+size[1]-1):
  4729. for x in range(pos[0]+1,pos[0]+size[0]-1):
  4730. m.tilemap[y][x] = tl.tlist['elfish'][4]
  4731. for i in range(0,num_beds):#set beds
  4732. pos = m.find_any(tl.tlist['elfish'][4])
  4733. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['functional'][8])
  4734. m.tilemap[pos[1]][pos[0]].replace = deepcopy(tl.tlist['building'][9])
  4735. m.tilemap[pos[1]][pos[0]].civilisation = False
  4736. m.tilemap[pos[1]][pos[0]].replace.civilisation = False
  4737. for i in range(0,num_furniture):#set furnaces
  4738. pos = m.find_any(tl.tlist['elfish'][4])
  4739. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['functional'][14])
  4740. m.tilemap[pos[1]][pos[0]].replace = deepcopy(tl.tlist['building'][9])
  4741. m.tilemap[pos[1]][pos[0]].civilisation = False
  4742. m.tilemap[pos[1]][pos[0]].replace.civilisation = False
  4743. for i in range(0,num_furniture):#set wb's
  4744. pos = m.find_any(tl.tlist['elfish'][4])
  4745. ran = random.randint(9,13)
  4746. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['functional'][ran])
  4747. m.tilemap[pos[1]][pos[0]].replace = deepcopy(tl.tlist['building'][9])
  4748. m.tilemap[pos[1]][pos[0]].civilisation = False
  4749. m.tilemap[pos[1]][pos[0]].replace.civilisation = False
  4750. for y in range(pos_original[1]+1,pos_original[1]+size[1]-1):#set blue floor
  4751. for x in range(pos_original[0]+1,pos_original[0]+size[0]-1):
  4752. if m.tilemap[y][x].techID == tl.tlist['elfish'][4].techID:
  4753. m.tilemap[y][x] = deepcopy(tl.tlist['building'][9])
  4754. m.tilemap[y][x].civilisation = False
  4755. screen.render_load(16,90)
  4756. for yy in range(0,max_map_size,5):
  4757. for xx in range(0,max_map_size):
  4758. if m.tilemap[yy][xx].techID == tl.tlist['elfish'][3].techID:#this is elfish wall
  4759. m.tilemap[yy][xx] = deepcopy(tl.tlist['building'][2]) #set a open door here
  4760. m.tilemap[yy][xx].civilisation = False
  4761. for yyy in range(yy-1,yy+2):
  4762. for xxx in range(xx-1,xx+2):
  4763. if yyy >= 0 and xxx >= 0 and xxx < max_map_size and yyy < max_map_size:
  4764. 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:
  4765. #if a field next to a door isn't elfish_indoor, elfish_wall or shop_floor set it to elfish_indoor
  4766. m.tilemap[yyy][xxx] = tl.tlist['elfish'][0]
  4767. screen.render_load(16,95)
  4768. for yy in range(0,max_map_size):
  4769. for xx in range(0,max_map_size,5):
  4770. if m.tilemap[yy][xx].techID == tl.tlist['elfish'][3].techID:#this is elfish wall
  4771. m.tilemap[yy][xx] = deepcopy(tl.tlist['building'][2]) #set a open door here
  4772. m.tilemap[yy][xx].civilisation = False
  4773. for yyy in range(yy-1,yy+2):
  4774. for xxx in range(xx-1,xx+2):
  4775. if yyy >= 0 and xxx >= 0 and xxx < max_map_size and yyy < max_map_size:
  4776. 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:
  4777. #if a field next to a door isn't elfish_indoor, elfish_wall or shop_floor set it to elfish_indoor
  4778. m.tilemap[yyy][xxx] = tl.tlist['elfish'][0]
  4779. screen.render_load(16,97)
  4780. m.cut(5,max_map_size-6,5,max_map_size-6,tl.tlist['elfish'][3])
  4781. m.set_frame(tl.tlist['functional'][0])
  4782. #set fontains
  4783. for y in range(10,max_map_size-10,10):
  4784. for x in range(10,max_map_size-10,10):
  4785. if m.tilemap[y][x].techID == tl.tlist['elfish'][1].techID:
  4786. coin = random.randint(0,1)
  4787. if coin == 0:
  4788. m.tilemap[y][x] = deepcopy(tl.tlist['functional'][7])#set a fontain
  4789. m.tilemap[y][x].replace = tl.tlist['elfish'][1]
  4790. m.tilemap[y][x].civilisation = False #this is no players fontain
  4791. m.exchange(tl.tlist['elfish'][5],tl.tlist['elfish'][0])
  4792. pos = m.find_any(tl.tlist['functional'][7]) #set portal home
  4793. if pos == False:
  4794. pos = m.find_any(tl.tlist['elfish'][1])
  4795. replace = deepcopy(tl.tlist['elfish'][1])
  4796. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['portal'][2])
  4797. m.tilemap[pos[1]][pos[0]].replace = replace
  4798. m.spawn_monsters(6)
  4799. self.maplist[layer][map_name] = m
  4800. screen.render_load(16,00)
  4801. def mine_generator(self,layer):
  4802. screen.render_load(17,1)
  4803. cave_name = 'dungeon_0_0'
  4804. m = self.default_map_generator(cave_name,'global_caves', tilelist)
  4805. m.map_type = 'orcish_mines'
  4806. m.set_music('orcish_mines','orcish_mines',True)
  4807. m.build_type = 'None'
  4808. m.monster_plus = 9
  4809. screen.render_load(17,10)
  4810. m.fill(tl.tlist['mine'][1])#fill with mine wall
  4811. screen.render_load(17,30)
  4812. m.drunken_walker(int(max_map_size/2),int(max_map_size/2),tl.tlist['mine'][0],((max_map_size**2/100)*45))
  4813. screen.render_load(17,50)
  4814. screen.render_load(17,60)
  4815. m.exchange_when_surrounded(tl.tlist['mine'][1],tl.tlist['global_caves'][3],8) #only the outer tiles become mine wall
  4816. screen.render_load(17,70)
  4817. for y in range (0, max_map_size):
  4818. for x in range(0,max_map_size):
  4819. if m.tilemap[y][x].techID == tl.tlist['global_caves'][3].techID:#this is hard rock
  4820. ran = random.randint(0,99)
  4821. if ran > 69:
  4822. m.tilemap[y][x] = tl.tlist['misc'][4]#set ore
  4823. m.tilemap[y][x].replace = tl.tlist['global_caves'][0]
  4824. elif ran < 10:
  4825. m.tilemap[y][x] = tl.tlist['misc'][5]#set gem
  4826. m.tilemap[y][x].replace = tl.tlist['global_caves'][0]
  4827. screen.render_load(17,80)
  4828. m.set_frame(tl.tlist['functional'][0])
  4829. m.make_shops()
  4830. m.make_containers(15,30,tl.tlist['mine'][0],1,4,'remains')
  4831. num_moss = int(((max_map_size*max_map_size)/100)*3)
  4832. for i in range (0,num_moss):
  4833. pos = m.find_any(tl.tlist['mine'][0])#find mine floor
  4834. try:
  4835. m.tilemap[pos[1]][pos[0]] = tl.tlist['mine'][2]#set blood moss
  4836. except:
  4837. None
  4838. screen.render_load(17,90)
  4839. pos = m.find_any(tl.tlist['mine'][0])#find any mine floor tile
  4840. m.tilemap[pos[1]][pos[0]] = tl.tlist['dungeon'][17]#set stair up
  4841. entrance_x = pos[0]
  4842. entrance_y = pos[1]
  4843. for sy in range(pos[1]-4,pos[1]+5):
  4844. for sx in range(pos[0]-4,pos[0]+5):
  4845. try:
  4846. if m.tilemap[sy][sx].move_group == 'soil':
  4847. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  4848. m.tilemap[sy][sx].move_group == 'dry_entrance'
  4849. elif m.tilemap[sy][sx].move_group == 'low_liquid':
  4850. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  4851. m.tilemap[sy][sx].move_group == 'wet_entrance'
  4852. except:
  4853. None
  4854. m.spawn_monsters(9)
  4855. screen.render_load(17,99)
  4856. self.maplist[layer][cave_name] = m
  4857. def cave_generator(self, deep, style='default'):
  4858. if style == 'desert':
  4859. cave_name='desert_0_0'
  4860. else:
  4861. cave_name = 'local_0_0'
  4862. p = 9
  4863. for d in range(1,deep+2):
  4864. screen.render_load(4,p+(d*20))
  4865. m = self.default_map_generator(cave_name,'global_caves', tilelist)
  4866. if d < 4:
  4867. if style == 'desert':
  4868. m.map_type = 'desert_cave'
  4869. m.monster_plus = 7
  4870. else:
  4871. m.map_type = 'cave'
  4872. m.set_music('cave','cave',True)
  4873. else:
  4874. if style == 'desert':
  4875. m.map_type = 'desert_lava_cave'
  4876. m.monster_plus = 7
  4877. else:
  4878. m.map_type = 'lava_cave'
  4879. m.set_music('lava_cave','lava_cave',True)
  4880. m.thirst_multi_day = 2
  4881. m.thirst_multi_night = 2
  4882. if d > 3:
  4883. m.exchange(tl.tlist['global_caves'][4],tl.tlist['misc'][2])#exchange lava against hot cave ground
  4884. m.exchange(tl.tlist['global_caves'][1],tl.tlist['misc'][28])#exchange worn rock against obsidian
  4885. if d > 4:
  4886. m.exchange_when_surrounded(tl.tlist['misc'][2],tl.tlist['global_caves'][4],8)#make lava spots between hot cave ground
  4887. num = int((max_map_size*max_map_size)/(50*50))
  4888. for i in range(0,num):
  4889. ran = random.randint(0,1)
  4890. if ran > 0:
  4891. pos = m.find_any(tl.tlist['global_caves'][0]) #cave ground
  4892. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['functional'][23])# make master forges
  4893. else:
  4894. m.exchange(tl.tlist['global_caves'][4],tl.tlist['misc'][1])#exchange lava against mud
  4895. m.exchange_when_surrounded(tl.tlist['misc'][1],tl.tlist['misc'][0],8)#make low water spots between mud
  4896. #######set mushrooms, ore and gems
  4897. chance_ore = d
  4898. chance_gem = d/2
  4899. for y in range (0,max_map_size):
  4900. for x in range (0,max_map_size):
  4901. if m.tilemap[y][x].techID == tl.tlist['global_caves'][3].techID:#this is hard rock
  4902. replace = m.tilemap[y][x].replace
  4903. coin = random.randint(0,1)
  4904. percent = random.randint(1,100)
  4905. if coin == 0 and percent <= chance_ore:
  4906. m.tilemap[y][x] = tl.tlist['misc'][4]#set ore here
  4907. m.tilemap[y][x].replace = replace
  4908. elif coin == 1 and percent <= chance_gem:
  4909. m.tilemap[y][x] = tl.tlist['misc'][5]#set gem here
  4910. m.tilemap[y][x].replace = replace
  4911. if m.tilemap[y][x].techID == tl.tlist['misc'][1].techID:#this is mud
  4912. cent = random.randint(0,99)
  4913. if cent < 10: #its a chance of 10% that a blue mushroom spawns here
  4914. replace = m.tilemap[y][x]
  4915. m.tilemap[y][x] = tl.tlist['misc'][6]
  4916. m.tilemap[y][x].replace = replace
  4917. if m.tilemap[y][x].techID == tl.tlist['global_caves'][0].techID:#this is cave ground
  4918. cent = random.randint(0,99)
  4919. if cent < 10: #its a chance of 10% that a brown mushroom spawns here
  4920. replace = m.tilemap[y][x]
  4921. m.tilemap[y][x] = tl.tlist['misc'][7]
  4922. m.tilemap[y][x].replace = replace
  4923. elif cent < 15: #its a chance of 5% that a purple mushroom spawns here
  4924. replace = m.tilemap[y][x]
  4925. m.tilemap[y][x] = tl.tlist['misc'][8]
  4926. m.tilemap[y][x].replace = replace
  4927. m.set_frame(tl.tlist['functional'][0])
  4928. if d == 1 and style == 'default':#set stair up on lvl 1
  4929. pos = (int(max_map_size/2),int(max_map_size/2))
  4930. m.tilemap[pos[1]+1][pos[0]] = deepcopy(tl.tlist['functional'][2])#stair down
  4931. m.tilemap[pos[1]+1][pos[0]].damage = -1
  4932. m.tilemap[pos[1]+1][pos[0]].damage_mes = 'Your wounds are cured.'
  4933. m.tilemap[pos[1]+1][pos[0]].build_here = False
  4934. for yy in range(pos[1]-3,pos[1]+4):
  4935. for xx in range(pos[0]-3,pos[0]+4):
  4936. m.tilemap[yy][xx].no_spawn = True
  4937. for x in range(0,max_map_size):
  4938. if m.tilemap[x][pos[0]].techID == tl.tlist['global_caves'][3].techID:#this is hard rock
  4939. ran = random.randint(1,2)
  4940. m.tilemap[x][pos[0]] = deepcopy(tl.tlist['global_caves'][ran])
  4941. for y in range(0,max_map_size):
  4942. if m.tilemap[pos[1]+1][y].techID == tl.tlist['global_caves'][3].techID:#this is hard rock
  4943. ran = random.randint(1,2)
  4944. m.tilemap[pos[1]+1][y] = deepcopy(tl.tlist['global_caves'][ran])
  4945. #set vaults
  4946. for i in range(0,int(max_map_size**2/50**2)):
  4947. m.make_vault(tl.tlist['global_caves'][0],d)
  4948. #set grot/mine at lvl 1 and 3
  4949. if style == 'default':
  4950. if d == 1:
  4951. ran_pos = m.find_any(tl.tlist['global_caves'][0])
  4952. m.tilemap[ran_pos[1]][ran_pos[0]] = tl.tlist['dungeon'][14]
  4953. if style == 'desert':
  4954. if d == 3:
  4955. ran_pos = m.find_any(tl.tlist['global_caves'][0])
  4956. m.tilemap[ran_pos[1]][ran_pos[0]] = tl.tlist['dungeon'][16]
  4957. m.make_containers(1,2,tl.tlist['global_caves'][0],2,5,'chest')#set some chests
  4958. m.make_special_monsters(0,1,tl.tlist['global_caves'][0],d,'mimic')#maybe set some mimics
  4959. m.make_special_monsters(15,25,tl.tlist['global_caves'][0],d,'vase')#set some vases
  4960. if m.map_type == 'desert_lava_cave':
  4961. m.make_special_monsters(1,2,tl.tlist['global_caves'][0],d,'demonic chest')#maybe set some demonic chests
  4962. m.spawn_monsters(d)
  4963. if style == 'desert': #replace rock etc.
  4964. for y in range(0,max_map_size):
  4965. for x in range(0,max_map_size):
  4966. if m.tilemap[y][x].techID == tl.tlist['global_caves'][3].techID: #this is hard rock
  4967. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][24])
  4968. elif m.tilemap[y][x].techID == tl.tlist['global_caves'][1].techID: #this is worn rock
  4969. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][23])
  4970. elif m.tilemap[y][x].techID == tl.tlist['global_caves'][2].techID: #this is soft soil
  4971. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][23])
  4972. elif m.tilemap[y][x].techID == tl.tlist['misc'][4].techID: #this is ore
  4973. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][21])
  4974. elif m.tilemap[y][x].techID == tl.tlist['misc'][5].techID: #this is gem
  4975. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][22])
  4976. elif m.tilemap[y][x].techID == tl.tlist['misc'][7].techID: #this is a brown mushroom
  4977. replace = m.tilemap[y][x].replace
  4978. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][25])
  4979. m.tilemap[y][x].replace = replace
  4980. elif m.tilemap[y][x].techID == tl.tlist['misc'][8].techID: #this is a purple mushroom
  4981. replace = m.tilemap[y][x].replace
  4982. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][27])
  4983. m.tilemap[y][x].replace = replace
  4984. elif m.tilemap[y][x].techID == tl.tlist['misc'][6].techID: #this is a blue mushroom
  4985. replace = m.tilemap[y][x].replace
  4986. m.tilemap[y][x] = deepcopy(tl.tlist['misc'][26])
  4987. m.tilemap[y][x].replace = replace
  4988. self.maplist[d][cave_name] = m
  4989. def elysium_generator(self):
  4990. name = 'elysium_0_0'
  4991. tilemap = []
  4992. for a in range (0,max_map_size):
  4993. tilemap.append([])
  4994. for b in range (0,max_map_size):
  4995. tilemap[a].append(0)
  4996. m = maP(name,tilemap)
  4997. m.map_type = 'elysium'
  4998. m.set_music('menu','menu',True)
  4999. m.fill(tl.tlist['sanctuary'][0])
  5000. for x in range(0,max_map_size):
  5001. for y in range(0,max_map_size):
  5002. if x%2 == 0 and y%2 == 0:
  5003. m.tilemap[y][x] = deepcopy(tl.tlist['sanctuary'][1])
  5004. elif x%2 != 0 and y%2 != 0:
  5005. m.tilemap[y][x] = deepcopy(tl.tlist['sanctuary'][1])
  5006. center = int(max_map_size/2)
  5007. for yy in range(center-2,center+3):
  5008. for xx in range(center-2,center+3):
  5009. m.tilemap[yy][xx] = deepcopy(tl.tlist['sanctuary'][0])
  5010. m.tilemap[center][center] = deepcopy(tl.tlist['sanctuary'][2])
  5011. for yyy in range(center-7,center-3):
  5012. for xxx in range(center-2,center+3):
  5013. m.tilemap[yyy][xxx] = deepcopy(tl.tlist['sanctuary'][0])
  5014. for yyy in range(center-2,center+3):
  5015. for xxx in range(center-7,center-3):
  5016. m.tilemap[yyy][xxx] = deepcopy(tl.tlist['sanctuary'][0])
  5017. for yyy in range(center-2,center+3):
  5018. for xxx in range(center+4,center+8):
  5019. m.tilemap[yyy][xxx] = deepcopy(tl.tlist['sanctuary'][0])
  5020. help_map = deepcopy(m)
  5021. for yyy in range(0,max_map_size):
  5022. for xxx in range(0,max_map_size):
  5023. if m.tilemap[yyy][xxx].techID == tl.tlist['sanctuary'][0].techID:
  5024. count = 0
  5025. for yyyy in range(yyy-1,yyy+2):
  5026. for xxxx in range(xxx-1,xxx+2):
  5027. try:
  5028. if m.tilemap[yyyy][xxxx].techID == tl.tlist['sanctuary'][1].techID:
  5029. count += 1
  5030. except:
  5031. None
  5032. if count == 4:
  5033. help_map.tilemap[yyy][xxx] = deepcopy(tl.tlist['sanctuary'][1])
  5034. m = help_map
  5035. m.tilemap[center][center-1] = deepcopy(tl.tlist['sanctuary'][3])
  5036. m.tilemap[center][center+1] = deepcopy(tl.tlist['sanctuary'][3])
  5037. m.tilemap[center][center-5] = deepcopy(tl.tlist['sanctuary'][3])
  5038. m.tilemap[center][center+5] = deepcopy(tl.tlist['sanctuary'][3])
  5039. m.tilemap[center][center-1] = deepcopy(tl.tlist['sanctuary'][3])
  5040. m.tilemap[center-5][center] = deepcopy(tl.tlist['sanctuary'][3])
  5041. m.tilemap[center-7][center] = deepcopy(tl.tlist['portal'][6])
  5042. m.tilemap[center-7][center].replace = deepcopy(tl.tlist['sanctuary'][0])
  5043. m.tilemap[center-8][center+1] = deepcopy(tl.tlist['portal'][0])
  5044. m.tilemap[center-8][center+1].replace = deepcopy(tl.tlist['sanctuary'][0])
  5045. m.tilemap[center-8][center-1] = deepcopy(tl.tlist['portal'][3])
  5046. m.tilemap[center-8][center-1].replace = deepcopy(tl.tlist['sanctuary'][0])
  5047. m.npcs[center-2][center] = deepcopy(ml.mlist['pet'][0])
  5048. m.npcs[center-2][center].lvl = 1
  5049. m.npcs[center-2][center].lp = 999
  5050. m.tilemap[center+2][center] = deepcopy(tl.tlist['functional'][20]) #divine gift
  5051. m.tilemap[center+2][center].replace = tl.tlist['sanctuary'][0] #
  5052. m.countdowns.append(countdown('gift_to_workbench',center,center+2,1)) #
  5053. #
  5054. material_pick = random.randint(0,10) #
  5055. material_axe = random.randint(0,10) #
  5056. material_amo = random.randint(0,10) #
  5057. amo_classes = ('shoes','cuisse','armor','helmet') #
  5058. ran = random.randint(0,3) #
  5059. amo_class = amo_classes[ran] #
  5060. #
  5061. pick = item_wear('pickaxe', material_pick,0) #
  5062. axe = item_wear('axe',material_axe,0) #
  5063. amo = item_wear(amo_class,material_amo,0) #
  5064. ran_tunica = random.randint(0,2) #
  5065. #
  5066. #original #
  5067. m.add_container([pick,axe,amo,il.ilist['misc'][53],il.ilist['misc'][2],il.ilist['misc'][51],il.ilist['clothe'][ran_tunica]],center,center+2)
  5068. #/original
  5069. self.maplist[0][name] = m
  5070. def grassland_generator(self,x,y,chance_scrubs, chance_trees, chance_herbs, number_rocks):
  5071. # chance_scrubs and chance_trees must be between 0 and 99
  5072. screen.render_load(3,1)
  5073. name = 'local_0_0'
  5074. helpmap = self.default_map_generator('1','help',tilelist)
  5075. tilemap = []
  5076. for a in range (0,max_map_size):
  5077. tilemap.append([])
  5078. for b in range (0,max_map_size):
  5079. tilemap[a].append(0)
  5080. m = maP(name,tilemap)
  5081. m.map_type = 'overworld'
  5082. m.set_music('overworld','night',True)
  5083. screen.render_load(3,2)
  5084. m.fill(tl.tlist['local'][0])#fill the map with grass
  5085. # set scrubs
  5086. for y in range (0,max_map_size):
  5087. for x in range (0,max_map_size):
  5088. if helpmap.tilemap[y][x].techID == tl.tlist['help'][0].techID: #<---scrub here
  5089. chance = random.randint(0,99)
  5090. if chance < chance_scrubs:
  5091. scrubs = (1,3,4,6,7,8,9)
  5092. coin = random.randint(0,len(scrubs)-1)
  5093. m.tilemap[y][x] = deepcopy(tl.tlist['local'][scrubs[coin]])
  5094. m.tilemap[y][x].replace = tl.tlist['local'][0]
  5095. screen.render_load(3,3)
  5096. #set trees
  5097. for y in range (0,max_map_size):
  5098. for x in range (0,max_map_size):
  5099. if helpmap.tilemap[y][x].techID == tl.tlist['help'][1].techID: #<---tree here
  5100. chance = random.randint(0,99)
  5101. if chance < chance_trees:
  5102. coin = random.randint(10,13)
  5103. m.tilemap[y][x] = tl.tlist['local'][coin]
  5104. m.tilemap[y][x].replace = tl.tlist['local'][0]#grass
  5105. screen.render_load(3,4)
  5106. #set herbs
  5107. for y in range (0,max_map_size):
  5108. for x in range (0,max_map_size):
  5109. if helpmap.tilemap[y][x].techID == tl.tlist['help'][0].techID: #<---scrub here
  5110. chance = random.randint(0,99)
  5111. if chance < chance_herbs:
  5112. coin = random.randint(15,16)
  5113. m.tilemap[y][x] = tl.tlist['local'][coin]
  5114. m.tilemap[y][x].replace = tl.tlist['local'][0]#grass
  5115. screen.render_load(3,5)
  5116. # set rocks
  5117. for n in range (0,number_rocks):
  5118. x = random.randint(0,max_map_size-1)
  5119. y = random.randint(0,max_map_size-1)
  5120. m.tilemap[y][x] = tl.tlist['local'][14]
  5121. m.tilemap[y][x].replace = tl.tlist['local'][0]#grass
  5122. screen.render_load(3,6)
  5123. #set water
  5124. for y in range (0,max_map_size):
  5125. for x in range (0,max_map_size):
  5126. if helpmap.tilemap[y][x].techID == tl.tlist['help'][2].techID: #<---water here
  5127. m.tilemap[y][x] = tl.tlist['misc'][0] # set low water here
  5128. screen.render_load(3,7)
  5129. m.exchange_when_surrounded(tl.tlist['misc'][0],tl.tlist['misc'][3],8) # exchange low wather against deep water
  5130. pos = (int(max_map_size/2),int(max_map_size/2))
  5131. #set portal
  5132. m.tilemap[pos[1]][pos[0]-5] = deepcopy(tl.tlist['portal'][8])
  5133. m.tilemap[pos[1]][pos[0]-5].replace = tl.tlist['local'][0]
  5134. #set stair down
  5135. m.tilemap[pos[1]+1][pos[0]] = deepcopy(tl.tlist['functional'][1])
  5136. m.set_frame(tl.tlist['functional'][0])
  5137. screen.render_load(3,8)
  5138. #set dungeon
  5139. ran_pos = m.find_any(tl.tlist['local'][0])
  5140. m.tilemap[ran_pos[1]][ran_pos[0]] = deepcopy(tl.tlist['dungeon'][7])
  5141. for q in range(0,int(max_map_size**2/50**2)*3):
  5142. m.make_orc_cave(tl.tlist['local'][0])#generate orc caves on grass
  5143. m.spawn_monsters(0)
  5144. self.maplist[0][name] = m
  5145. screen.render_load(3,9)
  5146. return pos
  5147. def shop_generator(self,style):
  5148. #0: Basic initializing
  5149. screen.render_load(19,0)
  5150. name = 'shop_0_0'
  5151. tilemap = []
  5152. for a in range (0,max_map_size):
  5153. tilemap.append([])
  5154. for b in range (0,max_map_size):
  5155. tilemap[a].append(0)
  5156. m = maP(name,tilemap)
  5157. m.map_type = style
  5158. m.build_type = 'None'
  5159. m.monster_plus = 0
  5160. m.monster_num = 0
  5161. m.set_music('shop','shop',True)
  5162. m.fill(tl.tlist['functional'][0])
  5163. screen.render_load(19,10)
  5164. center_x = int(max_map_size/2)
  5165. center_y = int(max_map_size/2)
  5166. for y in range(center_y-4,center_y+5):
  5167. for x in range(center_x-4,center_x+5):
  5168. m.tilemap[y][x] = deepcopy(tl.tlist['shop'][1])#wall
  5169. screen.render_load(19,20)
  5170. for y in range(center_y-3,center_y+4):
  5171. for x in range(center_x-3,center_x+4):
  5172. m.tilemap[y][x] = deepcopy(tl.tlist['dungeon'][1])#corridor
  5173. screen.render_load(19,30)
  5174. for y in range(center_y-2,center_y+3):
  5175. for x in range(center_x-2,center_x+3):
  5176. m.tilemap[y][x] = deepcopy(tl.tlist['shop'][1])#shop wall
  5177. screen.render_load(19,50)
  5178. for y in range(center_y-1,center_y+2):
  5179. for x in range(center_x-1,center_x+2):
  5180. m.tilemap[y][x] = deepcopy(tl.tlist['shop'][0])#shop floor
  5181. screen.render_load(19,70)
  5182. m.tilemap[center_y-2][center_x] = deepcopy(tl.tlist['shop'][2])#shop door
  5183. m.tilemap[center_y-3][center_x-1] = deepcopy(tl.tlist['shop'][5])#sign
  5184. m.tilemap[center_y-3][center_x-1].replace = deepcopy(tl.tlist['dungeon'][1])
  5185. m.tilemap[center_y-3][center_x].techID = -9999#nothing shall spawn here
  5186. m.tilemap[center_y-4][center_x] = deepcopy(tl.tlist['shop'][3])#shop exit
  5187. if style == 'pharmacy':
  5188. m.tilemap[center_y-3][center_x-1].move_mes = '[Naeria\'s Pharmacy]'
  5189. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][3])
  5190. elif style == 'pickaxe':
  5191. m.tilemap[center_y-3][center_x-1].move_mes = '[Eklor\'s Pickaxe Empire]'
  5192. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][4])
  5193. elif style == 'hardware':
  5194. m.tilemap[center_y-3][center_x-1].move_mes = '[Grimork\'s Hardware Store]'
  5195. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][5])
  5196. elif style == 'deco':
  5197. m.tilemap[center_y-3][center_x-1].move_mes = '[Larosa\'s Decoration Store]'
  5198. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][6])
  5199. elif style == 'book':
  5200. m.tilemap[center_y-3][center_x-1].move_mes = '[Xirazzzia\'s Bookshelf]'
  5201. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][7])
  5202. elif style == 'bomb':
  5203. m.tilemap[center_y-3][center_x-1].move_mes = '[Torguly\'s eXplozives Of al kinD]'
  5204. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][8])
  5205. elif style == 'general':
  5206. m.tilemap[center_y-3][center_x-1].move_mes = '[Arialu\'s General Store]'
  5207. m.npcs[center_y][center_x] = deepcopy(ml.mlist['shop'][9])
  5208. screen.render_load(19,90)
  5209. coin = random.randint(0,1)
  5210. if coin == 1:
  5211. pos = m.find_any(tl.tlist['dungeon'][1])
  5212. coin2 = random.randint(0,3)
  5213. if coin2 == 0:
  5214. replace = m.tilemap[pos[1]][pos[0]]
  5215. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['misc'][9])
  5216. m.tilemap[pos[1]][pos[0]].replace = replace
  5217. elif coin2 == 1:
  5218. replace = m.tilemap[pos[1]][pos[0]]
  5219. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['misc'][11])
  5220. m.tilemap[pos[1]][pos[0]].replace = replace
  5221. elif coin2 == 2:
  5222. m.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['cave'][2])
  5223. m.set_monster_strength(pos[0],pos[1],1)
  5224. else:
  5225. m.make_special_monsters(1,2,tl.tlist['dungeon'][1],1,'vase')
  5226. self.maplist[1][name] = m
  5227. screen.render_load(19,99)
  5228. def dungeon_generator(self,monster_plus,stair_down=True,num_traps=10,style='Dungeon'):#possible other style = 'Tomb'
  5229. #0: Basic initializing
  5230. screen.render_load(19,0)#Render progress bar 0%
  5231. if player.pet_pos != False and player.pet_on_map != False:
  5232. pet_help = deepcopy(world.maplist[player.pet_pos[2]][player.pet_on_map].npcs[player.pet_pos[1]][player.pet_pos[0]])
  5233. world.maplist[player.pet_pos[2]][player.pet_on_map].npcs[player.pet_pos[1]][player.pet_pos[0]] = 0
  5234. player.pet_pos = [0,0,1]
  5235. player.pet_on_map = 'dungeon_0_0'
  5236. if style == 'Tomb': #Set the graphics
  5237. tl.tlist['dungeon'][1].tile_pos = (4,6) #
  5238. tl.tlist['dungeon'][6].tile_pos = (4,7) #Sandstone walls,hidden doors and corridors for the acient tomb
  5239. tl.tlist['dungeon'][9].tile_pos = (4,7) #
  5240. else: #
  5241. tl.tlist['dungeon'][1].tile_pos = (10,6) #
  5242. tl.tlist['dungeon'][6].tile_pos = (2,6) #Default walls,hidden doors and corridors for the default dungeon
  5243. tl.tlist['dungeon'][9].tile_pos = (2,6) #
  5244. name = 'dungeon_0_0'#map name
  5245. tilemap = [] #Initializing a empty tilemap
  5246. for a in range (0,max_map_size): #
  5247. tilemap.append([]) #
  5248. for b in range (0,max_map_size): #
  5249. tilemap[a].append(0) #
  5250. m = maP(name,tilemap) #Generate a Map-object
  5251. if style == 'Tomb': #
  5252. m.map_type = 'tomb' #
  5253. m.set_music('tomb','tomb',True) #
  5254. else: #
  5255. m.map_type = 'dungeon' #and set a few constants for the new map
  5256. m.set_music('dungeon','dungeon',True)#
  5257. m.build_type = 'None' #
  5258. m.monster_plus = monster_plus #
  5259. m.monster_num = 0.3 #
  5260. m.no_monster_respawn = True #
  5261. m.fill(tl.tlist['dungeon'][9])#fill the map with dungeon wall tiles
  5262. screen.render_load(19,10)#Render progress bar 10%
  5263. #1: Set rooms
  5264. #Important fact: No matter how big the mapsize is set,
  5265. #dundeons only use the 52x52 tiles in the upper left connor.
  5266. #Thats as big as a small map.
  5267. test_build = True #Seperate the dungeon in a 3x3 grit.
  5268. while test_build: #Every part of the grit has a 66% chance to be a room
  5269. parts_with_rooms = [] #
  5270. #
  5271. for part_y in range(0,3): #
  5272. for part_x in range(0,3): #
  5273. ran = random.randint(0,9) #
  5274. if ran > 3: #
  5275. pick = (part_x,part_y) #
  5276. parts_with_rooms.append(pick) #
  5277. if len(parts_with_rooms) > 5: #every dungeon level needs at least 5 rooms
  5278. test_build = False #
  5279. coord_x = [] #transform the coordinates from the 3x3 grit into
  5280. coord_y = [] #real coordinates on the tilemap(center of the rooms)
  5281. #
  5282. for c in parts_with_rooms: #
  5283. x_offset = random.randint(0,5) #
  5284. y_offset = random.randint(0,5) #
  5285. #
  5286. real_x = 9+(15*c[0])+x_offset #
  5287. real_y = 9+(15*c[1])+y_offset #
  5288. #
  5289. coord_x.append(real_x) #
  5290. coord_y.append(real_y) #
  5291. 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
  5292. for i in range(0,len(coord_x)-1):#set variable roome size for all rooms
  5293. x_minus = random.randint(2,4)#
  5294. x_plus = random.randint(3,5) #
  5295. y_minus = random.randint(2,4)#
  5296. y_plus = random.randint(3,5) #
  5297. for yy in range(coord_y[i]-y_minus-1,coord_y[i]+y_plus+1): #draw walls around the rooms
  5298. for xx in range(coord_x[i]-x_minus-1,coord_x[i]+x_plus+1): #
  5299. m.tilemap[yy][xx] = deepcopy(tl.tlist['dungeon'][9]) #
  5300. for yy in range(coord_y[i]-y_minus,coord_y[i]+y_plus): #draw the room floor
  5301. for xx in range(coord_x[i]-x_minus,coord_x[i]+x_plus): #
  5302. m.tilemap[yy][xx] = tl.tlist['dungeon'][0] #
  5303. screen.render_load(19,25) #progress bar 25%
  5304. #2: Set doors
  5305. for yyy in range(0,52):
  5306. for xxx in range(0,52): #the 52 is hard scripted to safe performance
  5307. 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
  5308. if m.tilemap[yyy-1][xxx].move_group == 'soil' and m.tilemap[yyy+1][xxx].move_group == 'soil': #
  5309. m.tilemap[yyy][xxx] = tl.tlist['dungeon'][3] #
  5310. elif m.tilemap[yyy][xxx-1].move_group == 'soil' and m.tilemap[yyy][xxx+1].move_group == 'soil': #
  5311. m.tilemap[yyy][xxx] = tl.tlist['dungeon'][3] #
  5312. for yyy in range(0,52):
  5313. for xxx in range(0,52): #the 52 is hard scripted to safe performance
  5314. if m.tilemap[yyy][xxx].techID == tl.tlist['dungeon'][3].techID: #Remove all doors that are next to another door.
  5315. size = m.get_quarter_size(xxx,yyy) #Only spare one door per wall
  5316. if size[0] > 1: #
  5317. for rx in range(xxx,xxx+size[0]+1): #
  5318. m.tilemap[yyy][rx] = deepcopy(tl.tlist['dungeon'][9]) #
  5319. rrx = int(xxx+((rx-xxx)/2)) #
  5320. m.tilemap[yyy][rrx] = tl.tlist['dungeon'][3] #
  5321. #
  5322. if m.tilemap[yyy-1][rrx].move_group != 'soil': #
  5323. m.tilemap[yyy-1][rrx] = tl.tlist['dungeon'][1] #
  5324. if m.tilemap[yyy+1][rrx].move_group != 'soil': #
  5325. m.tilemap[yyy+1][rrx] = tl.tlist['dungeon'][1] #
  5326. #
  5327. if size[1] > 1: #
  5328. for ry in range(yyy,yyy+size[1]+1): #
  5329. m.tilemap[ry][xxx] = deepcopy(tl.tlist['dungeon'][9]) #
  5330. rry = int(yyy+((ry-yyy)/2)) #
  5331. m.tilemap[rry][xxx] = tl.tlist['dungeon'][3] #
  5332. #
  5333. if m.tilemap[rry][xxx-1].move_group != 'soil': #
  5334. m.tilemap[rry][xxx-1] = tl.tlist['dungeon'][1] #
  5335. if m.tilemap[rry][xxx+1].move_group != 'soil': #
  5336. m.tilemap[rry][xxx+1] = tl.tlist['dungeon'][1] #
  5337. screen.render_load(19,40)#Render progress bar 40%
  5338. test = deepcopy(m) #Make a copy of the map as is
  5339. pos = test.find_first(tl.tlist['dungeon'][0]) #and performe a float test,
  5340. test.floating(pos[0],pos[1],tl.tlist['misc'][0],tl.tlist['dungeon'][9]) #in order to find not conected parts.
  5341. screen.render_load(19,50) #Render progress bar 50%
  5342. for yyy in range(0,52): #Remove not connected parts
  5343. for xxx in range(0,52): #
  5344. if test.tilemap[yyy][xxx].techID != tl.tlist['dungeon'][9].techID and test.tilemap[yyy][xxx].techID != tl.tlist['misc'][0].techID: #
  5345. m.tilemap[yyy][xxx] = tl.tlist['dungeon'][9] #
  5346. screen.render_load(19,60)#Render progress bar 60%
  5347. for yyy in range(0,52): #Randomize doors:
  5348. for xxx in range(0,52): #-normal door
  5349. #-resisting door
  5350. if m.tilemap[yyy][xxx].techID == tl.tlist['dungeon'][3].techID: #-etc.
  5351. ran = random.randint(3,6) #
  5352. m.tilemap[yyy][xxx] = tl.tlist['dungeon'][ran] #
  5353. if m.tilemap[yyy][xxx].techID == tl.tlist['dungeon'][9].techID: #Randomize wall design
  5354. ran_test = random.randint(0,99) #
  5355. if ran_test > 75: #
  5356. if style == 'Dungeon': #
  5357. ran = random.randint(0,2) #
  5358. m.tilemap[yyy][xxx].tile_pos = (11,0+ran) #
  5359. if style == 'Tomb': #
  5360. ran = random.randint(0,2) #
  5361. m.tilemap[yyy][xxx].tile_pos = (12,0+ran) #
  5362. screen.render_load(19,70)#Render progress bar 70%
  5363. #3: Make stairs
  5364. stair_up_pos = m.find_any(tl.tlist['dungeon'][0]) #Set a up leading stair on any floor tile.
  5365. entrance_x = stair_up_pos[0] #
  5366. entrance_y = stair_up_pos[1] #
  5367. if style == 'Tomb': #
  5368. m.tilemap[stair_up_pos[1]][stair_up_pos[0]] = tl.tlist['dungeon'][19] #
  5369. else: #
  5370. m.tilemap[stair_up_pos[1]][stair_up_pos[0]] = tl.tlist['dungeon'][8] #
  5371. for sy in range(stair_up_pos[1]-4,stair_up_pos[1]+5):
  5372. for sx in range(stair_up_pos[0]-4,stair_up_pos[0]+5):
  5373. try:
  5374. if m.tilemap[sy][sx].move_group == 'soil':
  5375. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  5376. m.tilemap[sy][sx].move_group = 'dry_entrance'
  5377. elif m.tilemap[sy][sx].move_group == 'low_liquid':
  5378. m.tilemap[sy][sx] = deepcopy(m.tilemap[sy][sx])
  5379. m.tilemap[sy][sx].move_group = 'wet_entrance'
  5380. except:
  5381. None
  5382. if stair_down == True: #If we are not on the deepest lvl:
  5383. stair_down_pos = m.find_any(tl.tlist['dungeon'][0]) #Set a down leading stair on any floor tile.
  5384. if style == 'Tomb': #
  5385. m.tilemap[stair_down_pos[1]][stair_down_pos[0]] = tl.tlist['dungeon'][18] #
  5386. else: #
  5387. m.tilemap[stair_down_pos[1]][stair_down_pos[0]] = tl.tlist['dungeon'][7] #
  5388. else: #Make a chest whit a reward on the deepest lvl instead
  5389. chest_pos = m.find_any(tl.tlist['dungeon'][0]) #
  5390. m.tilemap[chest_pos[1]][chest_pos[0]] = tl.tlist['dungeon'][20] #
  5391. m.tilemap[chest_pos[1]][chest_pos[0]].replace = tl.tlist['dungeon'][0] #
  5392. if style == 'Tomb':
  5393. 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
  5394. else: #
  5395. m.add_container([il.ilist['special_clothe'][1],il.ilist['misc'][33],il.ilist['misc'][41]],chest_pos[0],chest_pos[1])#
  5396. for h in range(0,len(ml.mlist['vip_cage'])): #set vip_cages
  5397. p = m.find_any(tl.tlist['dungeon'][0]) #
  5398. m.npcs[p[1]][p[0]] = deepcopy(ml.mlist['vip_cage'][h]) #
  5399. m.set_monster_strength(p[0],p[1],1,lvl_bonus = 9) #
  5400. screen.render_load(19,80)#Render progress bar 80%
  5401. #4: Make Traps
  5402. for i in range(0,num_traps): #Set hidden traps on random floor tiles.
  5403. pos = m.find_any(tl.tlist['dungeon'][0]) #
  5404. replace = m.tilemap[pos[1]][pos[0]] #
  5405. m.tilemap[pos[1]][pos[0]] = deepcopy(tl.tlist['dungeon'][10]) #Traps have to be deepcopied to work proper.
  5406. m.tilemap[pos[1]][pos[0]].replace = replace #
  5407. screen.render_load(19,90) #Render Progress bar 90%
  5408. #5: Make interior
  5409. num_rooms = len(parts_with_rooms) #Make chests with random loot
  5410. m.make_containers(int(num_rooms/3),int(num_rooms/2),tl.tlist['dungeon'][0],1,3,'chest') #
  5411. for c in range(0,num_rooms): #Set random fontains on floor tiles
  5412. pos = m.find_any(tl.tlist['dungeon'][0]) #
  5413. ran = random.randint(0,99) #
  5414. if ran < 15: #
  5415. tile = deepcopy(tl.tlist['dungeon'][12]) #acid fontain
  5416. elif ran > 84: #
  5417. tile = deepcopy(tl.tlist['dungeon'][13]) #healing fontain
  5418. else: #
  5419. tile = deepcopy(tl.tlist['functional'][7]) #fontain
  5420. tile.civilisation = False #
  5421. tile.build_here = False #
  5422. tile.can_grown = False #
  5423. tile.replace = tl.tlist['dungeon'][0] #
  5424. m.tilemap[pos[1]][pos[0]] = tile #
  5425. coin = random.randint(0,1) #Set a Altar on 50% of all maps
  5426. if coin == 1: #that are generated with this function
  5427. pos = m.find_any(tl.tlist['dungeon'][0]) #
  5428. tile = deepcopy(tl.tlist['functional'][15]) #
  5429. tile.civilisation = False #
  5430. tile.build_here = False #
  5431. tile.can_grown = False #
  5432. tile.replace = tl.tlist['dungeon'][0] #
  5433. m.tilemap[pos[1]][pos[0]] = tile #
  5434. num_statue = random.randint(4,6) #generate random statues
  5435. for l in range(0,num_statue): #
  5436. kind = random.randint(0,len(tl.tlist['statue'])-1) #
  5437. pos = m.find_any(tl.tlist['dungeon'][0]) #
  5438. tile = deepcopy(tl.tlist['statue'][kind]) #
  5439. tile.replace = tl.tlist['dungeon'][0] #
  5440. m.tilemap[pos[1]][pos[0]] = tile #
  5441. num_deco = random.randint(8,10) #generate random deco
  5442. for l in range(0,num_deco): #
  5443. if style == 'Tomb': #
  5444. kind = random.randint(3,5) #
  5445. else: #
  5446. kind = random.randint(0,2) #
  5447. pos = m.find_any(tl.tlist['dungeon'][0]) #
  5448. tile = deepcopy(tl.tlist['deco'][kind]) #
  5449. tile.replace = tl.tlist['dungeon'][0] #
  5450. m.tilemap[pos[1]][pos[0]] = tile #
  5451. num_cage = random.randint(1,2) #spawn cages
  5452. for q in range(0,num_cage): #
  5453. pos = m.find_any(tl.tlist['dungeon'][0]) #
  5454. m.npcs[pos[1]][pos[0]] = deepcopy(ml.mlist['cage'][random.randint(0,len(ml.mlist['cage'])-1)]) #
  5455. m.set_monster_strength(pos[0],pos[1],1,lvl_bonus=9) #
  5456. m.spawn_monsters(0) #Spawn initial monsters
  5457. m.make_special_monsters(10,20,tl.tlist['dungeon'][0],m.monster_plus,'vase') #
  5458. m.make_special_monsters(1,2,tl.tlist['dungeon'][0],m.monster_plus,'mimic') #
  5459. if style == 'Tomb': #
  5460. m.make_special_monsters(1,3,tl.tlist['dungeon'][0],m.monster_plus,'demonic chest') #
  5461. coin = random.randint(0,1)
  5462. if coin == 1:
  5463. m.spawn_magic_shops()
  5464. m.npcs[0][0] = pet_help
  5465. self.maplist[1][name] = m # Add map to world.maplist
  5466. screen.render_load(19,99) #Render progress bar 99%
  5467. def desert_generator(self,chance_object):
  5468. #chance_objects must be between 0 and 99
  5469. screen.render_load(18,1)
  5470. name = 'desert_0_0'
  5471. tilemap = []
  5472. for a in range (0,max_map_size):
  5473. tilemap.append([])
  5474. for b in range (0,max_map_size):
  5475. tilemap[a].append(0)
  5476. m = maP(name,tilemap)
  5477. m.map_type = 'desert'
  5478. m.build_type = 'Full'
  5479. m.monster_plus = 7
  5480. m.thirst_multi_day = 2
  5481. m.set_music('desert','night',True)
  5482. m.fill(tl.tlist['extra'][0])
  5483. y_river = random.randint((17),(max_map_size-17))
  5484. river_offset = random.randint(-3,3)
  5485. plus = 0
  5486. minus = 0
  5487. screen.render_load(18,20)
  5488. for c in range (0,max_map_size):
  5489. for g in range (-2,7):
  5490. m.tilemap[y_river+river_offset+g][c] = tl.tlist['local'][0]#set grass
  5491. for w in range (0,5):
  5492. m.tilemap[y_river+river_offset+w][c] = tl.tlist['misc'][0]#set low water
  5493. if river_offset < 4:
  5494. plus = 1
  5495. else:
  5496. plus = 0
  5497. if river_offset > -4:
  5498. minus = -1
  5499. else:
  5500. minus = 0
  5501. offset_change = random.randint(minus,plus)
  5502. river_offset += offset_change
  5503. m.exchange_when_surrounded(tl.tlist['misc'][0],tl.tlist['misc'][3],7)
  5504. screen.render_load(18,40)
  5505. for b in range(2,max_map_size-2,10):
  5506. #north side of the river
  5507. building_offset =random.randint(0,4)
  5508. number_beds = 0
  5509. for y in range(y_river-12,y_river-7):
  5510. for x in range(b+building_offset,b+building_offset+5):
  5511. if x == b+building_offset or x == b+building_offset+4:
  5512. if y == y_river-10:
  5513. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][9])
  5514. else:
  5515. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][2])
  5516. elif y == y_river-12 or y == y_river-8:
  5517. if x == b+building_offset+2:
  5518. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][9])
  5519. else:
  5520. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][2])
  5521. else:
  5522. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][1])
  5523. if x == b+building_offset+1 or x == b+building_offset+3:
  5524. if y == y_river-11 or y == y_river-9:
  5525. obj_here = random.randint(0,2) #0: nothing, 1:bed 2:workbench
  5526. if number_beds == 0:
  5527. obj_here = 1
  5528. if obj_here != 0:
  5529. if obj_here == 1:
  5530. obj = ('functional',8)
  5531. number_beds += 1
  5532. else:
  5533. ran = random.randint(9,15)
  5534. obj = ('functional',ran)
  5535. m.tilemap[y][x] = deepcopy(tl.tlist[obj[0]][obj[1]])
  5536. m.tilemap[y][x].replace = deepcopy(tl.tlist['extra'][1])
  5537. m.tilemap[y][x].civilisation = False
  5538. m.tilemap[y][x].build_here = False
  5539. m.tilemap[y][x].move_group = 'house'
  5540. #south side of the river
  5541. building_offset = random.randint(0,4)
  5542. number_beds = 0
  5543. screen.render_load(18,60)
  5544. for y in range(y_river+8,y_river+13):
  5545. for x in range(b+building_offset,b+building_offset+5):
  5546. if x == b+building_offset or x == b+building_offset+4:
  5547. if y == y_river+10:
  5548. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][9])
  5549. else:
  5550. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][2])
  5551. elif y == y_river+12 or y == y_river+8:
  5552. if x == b+building_offset+2:
  5553. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][9])
  5554. else:
  5555. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][2])
  5556. else:
  5557. m.tilemap[y][x] = deepcopy(tl.tlist['extra'][1])
  5558. if x == b+building_offset+1 or x == b+building_offset+3:
  5559. if y == y_river+9 or y == y_river+11:
  5560. obj_here = random.randint(0,2) #0: nothing, 1:bed 2:workbench
  5561. if number_beds == 0:
  5562. obj_here = 1
  5563. if obj_here != 0:
  5564. if obj_here == 1:
  5565. obj = ('functional',8)
  5566. number_beds += 1
  5567. else:
  5568. ran = random.randint(9,15)
  5569. obj = ('functional',ran)
  5570. m.tilemap[y][x] = deepcopy(tl.tlist[obj[0]][obj[1]])
  5571. m.tilemap[y][x].replace = deepcopy(tl.tlist['extra'][1])
  5572. m.tilemap[y][x].civilisation = False
  5573. m.tilemap[y][x].build_here = False
  5574. m.tilemap[y][x].move_group = 'house'
  5575. make_bridges = True
  5576. num_bridges = 0
  5577. num_bridges_max = ((max_map_size/50)*3)+1
  5578. screen.render_load(18,80)
  5579. while num_bridges < num_bridges_max:
  5580. x_pos = random.randint(5,max_map_size-5)
  5581. num_wall = 0
  5582. for test in range(0,max_map_size):
  5583. if m.tilemap[test][x_pos].techID == tl.tlist['extra'][2].techID:
  5584. num_wall += 1
  5585. if num_wall == 0:
  5586. num_bridges += 1
  5587. for y in range(0,max_map_size):
  5588. 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
  5589. replace = deepcopy(m.tilemap[y][x_pos])
  5590. m.tilemap[y][x_pos] = deepcopy(tl.tlist['extra'][8])
  5591. m.tilemap[y][x_pos].replace = replace
  5592. for y in range (0,max_map_size):
  5593. for x in range (0,max_map_size):
  5594. if m.tilemap[y][x].techID == tl.tlist['extra'][0].techID:
  5595. chance = random.randint(0,99)
  5596. if chance < chance_object:
  5597. obj_numbers = (3,4,5,14)
  5598. coin = random.randint(0,len(obj_numbers)-1)
  5599. m.tilemap[y][x] = tl.tlist['extra'][obj_numbers[coin]]
  5600. m.tilemap[y][x].replace = tl.tlist['extra'][0]#sand
  5601. elif m.tilemap[y][x].techID == tl.tlist['local'][0].techID:
  5602. chance = random.randint(0,99)
  5603. if chance < chance_object:
  5604. coin = random.randint(10,13)
  5605. m.tilemap[y][x] = tl.tlist['extra'][coin]
  5606. m.tilemap[y][x].replace = tl.tlist['local'][0]#grass
  5607. elif m.tilemap[y][x].techID == tl.tlist['extra'][9].techID:
  5608. for yy in range(y-1,y+2):
  5609. if m.tilemap[yy][x].replace != None:
  5610. m.tilemap[yy][x] = m.tilemap[yy][x].replace
  5611. for xx in range(x-1,x+2):
  5612. if m.tilemap[y][xx].replace != None:
  5613. m.tilemap[y][xx] = m.tilemap[y][xx].replace
  5614. if m.tilemap[y][x].techID == tl.tlist['functional'][8].techID:#bed
  5615. ran = random.randint(5,6)
  5616. m.npcs[y][x] = deepcopy(ml.mlist['special'][ran])
  5617. m.set_monster_strength(x,y,0)
  5618. m.set_frame(tl.tlist['functional'][0])
  5619. screen.render_load(18,99)
  5620. #set portal
  5621. y = 2
  5622. x = random.randint(2,max_map_size-2)
  5623. m.tilemap[y][x] = tl.tlist['portal'][5]
  5624. m.tilemap[y][x].replace = tl.tlist['extra'][0]#sand
  5625. m.tilemap[y+1][x] = tl.tlist['extra'][0]#sand
  5626. #set tomb
  5627. ran_pos = m.find_any(tl.tlist['extra'][0])
  5628. m.tilemap[ran_pos[1]][ran_pos[0]] = tl.tlist['dungeon'][18]
  5629. m.spawn_monsters(0)
  5630. self.maplist[0][name] = m
  5631. class mob():
  5632. def __init__(self, name, on_map, attribute, pos =[40,40,0],glob_pos=[0,0],build='Manual'):
  5633. self.name = name
  5634. self.on_map = on_map
  5635. self.attribute = attribute
  5636. self.lp = attribute.max_lp
  5637. self.mp = attribute.max_mp
  5638. self.pos = pos
  5639. self.glob_pos = glob_pos
  5640. self.last_map = 'Foo'
  5641. self.cur_map = 'Bar'
  5642. self.cur_z = self.pos[2]
  5643. self.last_z = 'Baz'
  5644. def move(self, x=0, y=0):
  5645. mc = self.move_check(x,y)
  5646. tile_move_group = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group
  5647. player_move_groups = ['soil','low_liquid','shop','house','wet_entrance','dry_entrance']
  5648. swim_check = True
  5649. for i in ('Head','Body','Legs','Feet'):
  5650. if player.inventory.wearing[i] != player.inventory.nothing:
  5651. swim_check = False
  5652. if swim_check == True:
  5653. player_move_groups.append('swim')
  5654. if player.buffs.get_buff('hexed') < 1:
  5655. player_move_groups.append('holy')
  5656. if self.buffs.get_buff('immobilized') > 0:
  5657. player_move_groups = ['not_existent_group1','not_existent_group2']
  5658. move_check2 = False
  5659. for j in player_move_groups:
  5660. if j == tile_move_group:
  5661. move_check2 = True
  5662. if mc == True:
  5663. if x > 0 and move_check2 == True and self.pos[0] < max_map_size - 1:
  5664. if self.pet_pos != False and self.pet_on_map != False:
  5665. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].lp = 999 #set pets lp to 999 to make them unbreakable
  5666. world.maplist[self.pos[2]][self.on_map].npcs[self.pos[1]][self.pos[0]] = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]]
  5667. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]] = 0
  5668. self.pet_pos = deepcopy(self.pos)
  5669. self.pet_on_map = deepcopy(self.on_map)
  5670. self.pos[0] += 1
  5671. if x < 0 and move_check2 == True and self.pos[0] > 0:
  5672. if self.pet_pos != False and self.pet_on_map != False:
  5673. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].lp = 999 #set pets lp to 999 to make them unbreakable
  5674. world.maplist[self.pos[2]][self.on_map].npcs[self.pos[1]][self.pos[0]] = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]]
  5675. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]] = 0
  5676. self.pet_pos = deepcopy(self.pos)
  5677. self.pet_on_map = deepcopy(self.on_map)
  5678. self.pos[0] -= 1
  5679. if y > 0 and move_check2 == True and self.pos[1] < max_map_size - 1:
  5680. if self.pet_pos != False and self.pet_on_map != False:
  5681. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].lp = 999 #set pets lp to 999 to make them unbreakable
  5682. world.maplist[self.pos[2]][self.on_map].npcs[self.pos[1]][self.pos[0]] = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]]
  5683. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]] = 0
  5684. self.pet_pos = deepcopy(self.pos)
  5685. self.pet_on_map = deepcopy(self.on_map)
  5686. self.pos[1] += 1
  5687. if y < 0 and move_check2 == True and self.pos[1] > 0:
  5688. if self.pet_pos != False and self.pet_on_map != False:
  5689. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]].lp = 999 #set pets lp to 999 to make them unbreakable
  5690. world.maplist[self.pos[2]][self.on_map].npcs[self.pos[1]][self.pos[0]] = world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]]
  5691. world.maplist[self.pet_pos[2]][self.pet_on_map].npcs[self.pet_pos[1]][self.pet_pos[0]] = 0
  5692. self.pet_pos = deepcopy(self.pos)
  5693. self.pet_on_map = deepcopy(self.on_map)
  5694. self.pos[1] -= 1
  5695. self.stand_check()
  5696. def move_check(self,x,y):
  5697. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group == 'door':
  5698. 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:
  5699. #this is a resisting door or a hidden door
  5700. sfx.play('locked')
  5701. else:
  5702. sfx.play('open')
  5703. message.add(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_mes)
  5704. 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
  5705. return False
  5706. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group == 'shop_enter':
  5707. sfx.play('open')
  5708. screen.render_fade(True,False)
  5709. shop_types = ('pharmacy','pickaxe','hardware','deco','book','bomb','general')
  5710. ran = random.randint(0,len(shop_types)-1)
  5711. world.shop_generator(shop_types[ran])
  5712. self.save_pos=(self.pos[0],self.pos[1],self.pos[2],self.on_map)
  5713. 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
  5714. shop_pos = world.maplist[1]['shop_0_0'].find_first(tl.tlist['shop'][3])
  5715. self.pos[0] = shop_pos[0]
  5716. self.pos[1] = shop_pos[1]+1
  5717. self.pos[2] = 1
  5718. self.on_map = 'shop_0_0'
  5719. player.stand_check()
  5720. screen.render_fade(False,True)
  5721. return False
  5722. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group == 'shop_exit':
  5723. sfx.play('open')
  5724. self.pos[0] = self.save_pos[0]
  5725. self.pos[1] = self.save_pos[1]
  5726. self.pos[2] = self.save_pos[2]
  5727. self.on_map = self.save_pos[3]
  5728. player.stand_check()
  5729. screen.render_fade(False,True)
  5730. return False
  5731. try:
  5732. if world.maplist[self.pos[2]][self.on_map].npcs[self.pos[1]+y][self.pos[0]+x] != 0:
  5733. player.attack_monster(self.pos[0]+x,self.pos[1]+y)
  5734. return False
  5735. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].destroy != False: #for digging
  5736. 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
  5737. heated_stone = True
  5738. else:
  5739. heated_stone = False
  5740. if player.pos[2] > 3 and heated_stone == False:
  5741. brimstone = True
  5742. else:
  5743. brimstone = False
  5744. 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:
  5745. #this is not obsidian or soft soil
  5746. stone = True
  5747. else:
  5748. stone = False
  5749. 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:
  5750. if self == player:
  5751. message.add(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_mes)
  5752. 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
  5753. sfx.play('break')
  5754. try:
  5755. if self.skill.mining == 'Adept':
  5756. mat_addition = 2
  5757. elif self.skill.mining == 'Master':
  5758. mat_addition = 5
  5759. else:
  5760. mat_addition = 0
  5761. material = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].conected_resources[0]
  5762. mat_num = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].conected_resources[1] + mat_addition
  5763. mes = player.inventory.materials.add(material,mat_num)
  5764. message.add(mes)
  5765. if player.skill.mining != 'Master':
  5766. player.skill.mining_progress += 1
  5767. if player.skill.mining_progress == 200 and player.skill.mining != 'Adept':
  5768. player.skill.raise_skill('mining')
  5769. message.add('Your mining skill reaches adept level!')
  5770. sfx.play('lvl_up')
  5771. if player.skill.mining_progress == 1000 and player.skill.mining != 'Master':
  5772. player.skill.raise_skill('mining')
  5773. message.add('Your mining skill reaches master level!')
  5774. sfx.play('lvl_up')
  5775. except:
  5776. None
  5777. 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
  5778. world.maplist[self.pos[2]][self.on_map].countdowns.append(countdown('door', self.pos[0]+x, self.pos[1]+y,3))
  5779. sfx.play('open')
  5780. stone = False
  5781. heated_stone = False
  5782. brimstone = False
  5783. 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)
  5784. if heated_stone == True:#drop heated stone
  5785. ran = random.randint(0,99)
  5786. if ran < 5:
  5787. replace = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x]
  5788. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = deepcopy(tl.tlist['functional'][28])
  5789. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].replace = replace
  5790. elif brimstone == True:#drop brimstone
  5791. ran = random.randint(0,99)
  5792. if ran < 5:
  5793. replace = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x]
  5794. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = deepcopy(tl.tlist['functional'][29])
  5795. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].replace = replace
  5796. elif stone == True:#drop stone
  5797. ran = random.randint(0,99)
  5798. if ran < 5:
  5799. replace = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x]
  5800. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = deepcopy(tl.tlist['functional'][30])
  5801. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].replace = replace
  5802. 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:
  5803. player.inventory.wearing['Pickaxe'].take_damage()
  5804. if player.inventory.wearing['Pickaxe'].state > 0:
  5805. player.inventory.wearing['Pickaxe'].set_name()
  5806. else:
  5807. message.add('Your tool breaks into pieces.')
  5808. player.inventory.wearing['Pickaxe'] = player.inventory.nothing
  5809. sfx.play('item_break')
  5810. else:
  5811. if self == player:
  5812. message.add('You are unable to destroy this with the tool in your hand.')
  5813. return False
  5814. else:
  5815. None
  5816. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].move_group == 'tree':
  5817. 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
  5818. apple = True
  5819. else:
  5820. apple = False
  5821. if player.inventory.wearing['Axe'] != player.inventory.nothing: #if player has a axe in his hand
  5822. chop_success = True
  5823. player.inventory.wearing['Axe'].take_damage()
  5824. if player.inventory.wearing['Axe'].state > 0:
  5825. player.inventory.wearing['Axe'].set_name()
  5826. else:
  5827. message.add('Your axe breaks into pieces.')
  5828. player.inventory.wearing['Axe'] = player.inventory.nothing
  5829. sfx.play('item_break')
  5830. else:
  5831. message.add('That hurts!')
  5832. player.lp -= 1
  5833. sfx.play('hit')
  5834. if random.randint(0,9) != 0: #90% to fail chopping down the wood with bare hands
  5835. chop_success = False
  5836. else:
  5837. chop_success = True
  5838. if chop_success == True:
  5839. if self.skill.woodcutting == 'Adept':
  5840. mat_addition = 2
  5841. elif self.skill.woodcutting == 'Master':
  5842. mat_addition = 5
  5843. else:
  5844. mat_addition = 0
  5845. material = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].conected_resources[0]
  5846. mat_num = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].conected_resources[1] + mat_addition
  5847. mes = player.inventory.materials.add(material,mat_num)
  5848. message.add(mes)
  5849. sfx.play('chop')
  5850. if player.skill.woodcutting != 'Master':
  5851. player.skill.woodcutting_progress += 1
  5852. if player.skill.woodcutting_progress == 200 and player.skill.woodcutting != 'Adept':
  5853. player.skill.raise_skill('woodcutting')
  5854. message.add('Your woodcutting skill reaches adept level!')
  5855. sfx.play('lvl_up')
  5856. if player.skill.woodcutting_progress == 1000 and player.skill.woodcutting != 'Master':
  5857. player.skill.raise_skill('woodcutting')
  5858. message.add('Your woodcutting skill reaches master level!')
  5859. sfx.play('lvl_up')
  5860. world.maplist[self.pos[2]][self.on_map].make_monsters_angry(self.pos[0],self.pos[1],'tree')
  5861. 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
  5862. if apple == True:
  5863. ran = random.randint(0,99)
  5864. if ran < 5:
  5865. ran2 = random.randint(0,99)
  5866. replace = deepcopy(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x])
  5867. if ran2 < 20:
  5868. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = deepcopy(tl.tlist['functional'][32])
  5869. else:
  5870. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x] = deepcopy(tl.tlist['functional'][31])
  5871. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]+y][self.pos[0]+x].replace = replace
  5872. return False
  5873. if self.buffs.get_buff('immobilized') == 0:
  5874. 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':
  5875. sfx.play('walk_wet')
  5876. else:
  5877. sfx.play('walk_dry')
  5878. else:
  5879. sfx.play('immobilized')
  5880. return True
  5881. except:
  5882. None
  5883. def stand_check(self):
  5884. if self.on_map != 'shop_0_0':
  5885. if self.on_map != self.cur_map:
  5886. self.last_map = self.cur_map
  5887. self.cur_map = self.on_map
  5888. if self.pos[2] != self.cur_z:
  5889. self.last_z = self.cur_z
  5890. self.cur_z = self.pos[2]
  5891. world.maplist[self.pos[2]][self.on_map].special_check(self.pos[0],self.pos[1])
  5892. radius = 5
  5893. if player.pos[2] > 0:
  5894. radius = 2
  5895. elif player.pos[2] == 0:
  5896. if time.hour > 22 or time.hour < 4:
  5897. radius = 2
  5898. elif time.hour > 21 or time.hour < 5:
  5899. radius = 3
  5900. elif time.hour > 20 or time.hour < 6:
  5901. radius = 4
  5902. elif time.hour > 19 or time.hour < 7:
  5903. radius = 5
  5904. if player.buffs.get_buff('light') > 0 or player.buffs.get_buff('nightvision') > 0:
  5905. radius = 5
  5906. if player.buffs.get_buff('blind') > 0:
  5907. radius = 1
  5908. message.add(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].move_mes,True)
  5909. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].damage > 0 and player.buffs.get_buff('fireresistance') == 0:
  5910. self.lp = self.lp - world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].damage
  5911. if self == player:
  5912. try:
  5913. 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)')
  5914. except:
  5915. None
  5916. 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':
  5917. sfx_flame = False
  5918. body_list = ('Head','Body','Legs','Feet','Hold(R)','Hold(L)','Neck','Hand','Pickaxe','Axe')
  5919. for i in body_list:
  5920. if player.inventory.wearing[i] != player.inventory.nothing and player.inventory.wearing[i].material == 'wooden':
  5921. ran = random.randint(0,9)
  5922. if ran < 4:
  5923. message.add('Your '+player.inventory.wearing[i].name+' burns to ashes!')
  5924. player.inventory.wearing[i] = player.inventory.nothing
  5925. sfx_flame = True
  5926. if sfx_flame == True:
  5927. sfx.play('flame')
  5928. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].damage < 0:
  5929. if self.lp < self.attribute.max_lp:
  5930. self.lp = self.lp - world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].damage
  5931. luck = player.attribute.luck + player.inventory.wearing['Neck'].attribute.luck
  5932. for y in range(player.pos[1]-1,player.pos[1]+2):
  5933. for x in range(player.pos[0]-1,player.pos[0]+2):
  5934. if world.maplist[self.pos[2]][self.on_map].tilemap[y][x].techID == tl.tlist['dungeon'][6].techID:#this is a secret door
  5935. ran = random.randint(0,25)#check players luck
  5936. if ran < luck:
  5937. world.maplist[self.pos[2]][self.on_map].tilemap[y][x] = deepcopy(tl.tlist['dungeon'][3])
  5938. message.add('You notice a hidden door.')
  5939. screen.write_hit_matrix(player.pos[0],player.pos[1],14)
  5940. screen.write_hit_matrix(x,y,15)
  5941. sfx.play('found')
  5942. 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
  5943. ran = random.randint(0,25)#check players luck
  5944. if ran < luck:
  5945. world.maplist[self.pos[2]][self.on_map].tilemap[y][x].tile_pos = (10,8)
  5946. message.add('You notice a trap.')
  5947. screen.write_hit_matrix(player.pos[0],player.pos[1],14)
  5948. screen.write_hit_matrix(x,y,15)
  5949. sfx.play('found')
  5950. 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
  5951. ran = random.randint(0,15)#check players luck
  5952. if ran < luck:
  5953. world.maplist[self.pos[2]][self.on_map].tilemap[y][x].tile_pos = (12,11,12,12)
  5954. world.maplist[self.pos[2]][self.on_map].tilemap[y][x].use_group = 'dont_drink'
  5955. message.add('You notice a strange smell.')
  5956. screen.write_hit_matrix(player.pos[0],player.pos[1],14)
  5957. screen.write_hit_matrix(x,y,15)
  5958. sfx.play('found')
  5959. 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
  5960. ran = random.randint(0,15)#check players luck
  5961. if ran < luck:
  5962. world.maplist[self.pos[2]][self.on_map].tilemap[y][x].tile_pos = (11,11,11,12)
  5963. message.add('You notice a strange sparkle.')
  5964. screen.write_hit_matrix(player.pos[0],player.pos[1],14)
  5965. screen.write_hit_matrix(x,y,15)
  5966. sfx.play('found')
  5967. for y in range (-radius,radius+1):#line of sight
  5968. for x in range (-radius,radius+1):
  5969. try:
  5970. dist = ((x)**2+(y)**2)**0.5
  5971. if dist <= radius+1 or dist >= radius-1:
  5972. run = True
  5973. c = 0
  5974. while run:
  5975. try:
  5976. yy = ((y*c)/dist)
  5977. except:
  5978. yy = 1
  5979. try:
  5980. xx = ((x*c)/dist)
  5981. except:
  5982. xx = 1
  5983. view_x = int(xx) + self.pos[0]
  5984. view_y = int(yy) + self.pos[1]
  5985. world.maplist[self.pos[2]][self.on_map].known[view_y][view_x] = 1
  5986. if world.maplist[self.pos[2]][self.on_map].tilemap[view_y][view_x].transparency == True and c < radius:
  5987. c+=1
  5988. else:
  5989. run = False
  5990. except:
  5991. None
  5992. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].techID == tl.tlist['dungeon'][10].techID:
  5993. kind =random.randint(0,3)
  5994. position = deepcopy(player.pos)#copy player pos before the trap is triggered because teleport traps could change it
  5995. if kind == 0:#dart trap
  5996. ran = random.randint(0,25)
  5997. if ran < luck:
  5998. screen.write_hit_matrix(player.pos[0],player.pos[1],3)
  5999. message.add('A flying dagger miss you.')
  6000. sfx.play('miss')
  6001. else:
  6002. player.lp -= 3
  6003. screen.write_hit_matrix(player.pos[0],player.pos[1],4)
  6004. message.add('A flying dagger hits you.')
  6005. sfx.play('hit')
  6006. elif kind == 1:#teleport trap
  6007. t=world.maplist[self.pos[2]][self.on_map].find_all_moveable()
  6008. if len(t) > 0:
  6009. rt = []
  6010. for i in t:
  6011. if world.maplist[self.pos[2]][self.on_map].npcs[i[1]][i[0]] == 0:
  6012. rt.append((i[0],i[1]))
  6013. if len(rt) > 0:
  6014. screen.render_fade(True,False)
  6015. ran = random.randint(0,len(rt)-1)
  6016. player.pos[0] = rt[ran][0]
  6017. player.pos[1] = rt[ran][1]
  6018. screen.reset_hit_matrix()
  6019. message.add('You are teleported randomly.')
  6020. sfx.play('teleport')
  6021. player.stand_check()
  6022. screen.render_fade(False,True)
  6023. else:
  6024. message.add('Nothing seems to happen.')
  6025. sfx.play('throw')
  6026. elif kind == 2:#blinding trap
  6027. ran = random.randint(10,30)
  6028. player.buffs.set_buff('blind',ran)
  6029. message.add('A garish flash blinds you.')
  6030. elif kind == 3:#magic trap
  6031. player.mp = 0
  6032. screen.write_hit_matrix(player.pos[0],player.pos[1],7)
  6033. message.add('You loose your focus.')
  6034. replace = world.maplist[self.pos[2]][self.on_map].tilemap[position[1]][position[0]].replace
  6035. world.maplist[self.pos[2]][self.on_map].tilemap[position[1]][position[0]] = deepcopy(tl.tlist['dungeon'][11])
  6036. world.maplist[self.pos[2]][self.on_map].tilemap[position[1]][position[0]].replace = replace
  6037. if player.lp <= 0:
  6038. screen.render_dead()
  6039. self.lp = int(self.lp)
  6040. bgm.check_for_song()
  6041. if time.hour%2 == 0 and time.minute == 0:
  6042. help_player = deepcopy(player)
  6043. help_player.on_map = 'local_0_0'
  6044. help_player.pos[0] = max_map_size/2
  6045. help_player.pos[1] = max_map_size/2
  6046. help_player.pos[2] = 0
  6047. save(None,help_player,time,gods,save_path,os.sep)
  6048. def enter(self):
  6049. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'stair_down':
  6050. 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
  6051. screen.render_fade(True,False)
  6052. player.pos[2] += 1
  6053. player.stand_check()#to unveil the surroundings
  6054. screen.render_fade(False,True)
  6055. else:
  6056. message.add('This stair seem to be blocked.')
  6057. 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
  6058. 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
  6059. screen.render_fade(True,False)
  6060. player.pos[2] -= 1
  6061. player.stand_check()#to unveil the surroundings
  6062. screen.render_fade(False,True)
  6063. else:
  6064. message.add('This stair seem to be blocked.')
  6065. 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
  6066. #drink water
  6067. if player.attribute.thirst < player.attribute.thirst_max:
  6068. sfx.play('no_fish')
  6069. message.add('You take a sip of water.')
  6070. player.attribute.thirst += 240 #this is 1/3 of the water te player needs per day
  6071. if player.attribute.thirst > player.attribute.thirst_max:
  6072. 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%
  6073. else:
  6074. message.add('You are not thirsty right now.')
  6075. 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
  6076. #drink acid water
  6077. if player.attribute.thirst < player.attribute.thirst_max:
  6078. message.add('You take a sip of water.')
  6079. player.lp -= 5
  6080. message.add('It hurts like acid.')
  6081. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].tile_pos = (12,11,12,12)
  6082. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group = 'dont_drink'
  6083. else:
  6084. message.add('You are not thirsty right now.')
  6085. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'dont_drink':
  6086. message.add('You shouldn\'t drink this water!')
  6087. 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
  6088. #drink healing water
  6089. if player.attribute.thirst < player.attribute.thirst_max:
  6090. message.add('You take a sip of water.')
  6091. if player.lp < player.attribute.max_lp:
  6092. player.lp += 5
  6093. if player.lp > player.attribute.max_lp:
  6094. player.lp = player.attribute.max_lp
  6095. message.add('Your wounds are cured.')
  6096. replace = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace
  6097. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]] = deepcopy(tl.tlist['functional'][7])
  6098. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].civilisation = False
  6099. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].build_here = False
  6100. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].can_grown = False
  6101. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace = replace
  6102. else:
  6103. message.add('You are not thirsty right now.')
  6104. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'resource':
  6105. res = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_resources[0]
  6106. num = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_resources[1]
  6107. try:
  6108. 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])
  6109. except:
  6110. None
  6111. test = player.inventory.materials.add(res,num)
  6112. if test != 'Full!':
  6113. sfx.play('pickup')
  6114. message.add(test)
  6115. replace = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace
  6116. try:
  6117. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]] = deepcopy(tl.tlist[conected_tile[0]][conected_tile[1]])
  6118. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace = replace
  6119. except:
  6120. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]] = replace
  6121. else:
  6122. message.add(test)
  6123. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'sleep':#this is a bed
  6124. #sleep a bit
  6125. sleep = True
  6126. lp = player.lp
  6127. while sleep:
  6128. screen.render_load(12)
  6129. time.tick()
  6130. player.attribute.tiredness += 5
  6131. if player.buffs.get_buff('adrenalised') > 0:
  6132. player.buffs.buff_list['adrenalised'] -= 5
  6133. if player.buffs.get_buff('adrenalised') < 0:
  6134. player.buffs.buff_list['adrenalised'] = 0
  6135. if player.lp < lp:
  6136. message.add('You were hurt!')
  6137. sleep = False
  6138. if player.attribute.tiredness >= player.attribute.tiredness_max:#wake up because you've slept enough
  6139. 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%
  6140. message.add('You feel refreshed.')
  6141. sleep = False
  6142. if int((player.attribute.hunger_max*100)/max(player.attribute.hunger,1)) < 11:
  6143. message.add('You feel hungry.')
  6144. sleep = False
  6145. if int((player.attribute.thirst_max*100)/max(player.attribute.thirst,1)) < 11:
  6146. message.add('You feel thirsty.')
  6147. sleep = False
  6148. monster_test = False
  6149. for y in range (player.pos[1]-1, player.pos[1]+2):#check for a monster
  6150. for x in range (player.pos[0]-1, player.pos[0]+2):
  6151. try:
  6152. 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
  6153. monster_test = True
  6154. except:
  6155. None
  6156. if monster_test == True:#wake up because a monster borders the players sleep
  6157. message.add('You wake up with a sense of danger.')
  6158. sleep = False
  6159. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'gather':
  6160. help_container = container([world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_items])
  6161. item_name = help_container.items[0].name
  6162. test_loot = help_container.loot(0)
  6163. if test_loot == True:
  6164. sfx.play('pickup')
  6165. string = '+[' + item_name + ']'
  6166. message.add(string)
  6167. 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
  6168. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] = 0
  6169. else:
  6170. message.add('Your inventory is full!')
  6171. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'gather_scrub':
  6172. help_container = container([world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_items])
  6173. item_name = help_container.items[0].name
  6174. test_loot = help_container.loot(0)
  6175. if test_loot == True:
  6176. sfx.play('pickup')
  6177. string = '+[' + item_name + ']'
  6178. message.add(string)
  6179. cat = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_tiles[2][0]
  6180. num = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_tiles[2][1]
  6181. replace = world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace
  6182. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]] = tl.tlist[cat][num]
  6183. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace = replace
  6184. else:
  6185. message.add('Your inventory is full!')
  6186. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'carpenter':
  6187. #this is a carpenter's workbench
  6188. run = True
  6189. first_call = True
  6190. while run:
  6191. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6192. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6193. screen.render_request('['+key_name['e']+'] - produce something (-10 Wood)', '['+key_name['b']+'] - take a produced item', '['+key_name['x']+'] - leave',first_call)
  6194. else:
  6195. screen.render_request('['+key_name['e']+'] - XXXXXXXXXXXX ', '['+key_name['b']+'] - take a produced item', '['+key_name['x']+'] - leave',first_call)
  6196. else:
  6197. screen.render_request('['+key_name['e']+'] - produce something (-10 Wood)', '['+key_name['b']+'] - pick up workbench', '['+key_name['x']+'] - leave',first_call)
  6198. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,0,mouse=game_options.mousepad)
  6199. first_call = False
  6200. if ui == 'exit':
  6201. exitgame = True
  6202. screen.render_load(5)
  6203. save(world,player,time,gods,save_path,os.sep)
  6204. screen.save_tmp_png()
  6205. master_loop = False
  6206. playing = False
  6207. run = False
  6208. return('exit')
  6209. if ui == 'e':
  6210. test = False
  6211. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6212. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6213. test = True
  6214. else:
  6215. test = True
  6216. if test == True:
  6217. if player.inventory.materials.wood >= 10:
  6218. 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)
  6219. if gc == 'Break':
  6220. run = False
  6221. elif gc < 5:# give the chosen workbench to the player
  6222. items = (il.ilist['misc'][3],il.ilist['misc'][4],il.ilist['misc'][5],il.ilist['misc'][6],il.ilist['misc'][7])
  6223. choose = gc
  6224. elif gc == 5:
  6225. 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])
  6226. #chest, bed, table, w. seat, bookshelf
  6227. gc2 = screen.get_choice('What do you want to produce exactly?', ('Chest', 'Bed', 'Table', 'Seat', 'Throne', 'Bookshelf'),True)
  6228. choose = gc2
  6229. try:
  6230. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] == 0:
  6231. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] = container([items[choose]],False)
  6232. else:
  6233. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items.append(items[choose])
  6234. sfx.play('craft')
  6235. message_string = 'You produced a ' + items[choose].name + '.'
  6236. message.add(message_string)
  6237. player.inventory.materials.wood -= 10
  6238. except:
  6239. None
  6240. run = False
  6241. else:
  6242. message.add('You do not have enough wood!')
  6243. run = False
  6244. elif ui == 'b':
  6245. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6246. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].inventory(False)
  6247. run = False
  6248. else:
  6249. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace.techID != tl.tlist['sanctuary'][0].techID:
  6250. #this wb dosen't stand inside the sanctuary
  6251. helpc = container([il.ilist['misc'][3]],True)
  6252. item_name = helpc.items[0].name
  6253. test_loot = helpc.loot(0)
  6254. run = False
  6255. if test_loot == True:
  6256. sfx.play('pickup')
  6257. string = '+[' + item_name + ']'
  6258. message.add(string)
  6259. 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
  6260. else:
  6261. message.add('This workbench seems to be attached to the floor.')
  6262. run = False
  6263. elif ui == 'x':
  6264. run = False
  6265. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'carver':
  6266. #this is a carvers's workbench
  6267. run = True
  6268. first_call = True
  6269. while run:
  6270. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6271. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6272. screen.render_request('['+key_name['e']+'] - produce something (-5 Wood)', '['+key_name['b']+'] - take a produced item', '['+key_name['x']+'] - leave',first_call)
  6273. else:
  6274. screen.render_request('['+key_name['e']+'] - XXXXXXXXXXXX ', '['+key_name['b']+'] - take a produced item', '['+key_name['x']+'] - leave',first_call)
  6275. else:
  6276. screen.render_request('['+key_name['e']+'] - produce something (-5 Wood)', '['+key_name['b']+'] - pick up workbench', '['+key_name['x']+'] - leave',first_call)
  6277. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,0,mouse=game_options.mousepad)
  6278. first_call = False
  6279. if ui == 'exit':
  6280. exitgame = True
  6281. screen.render_load(5)
  6282. save(world,player,time,gods,save_path,os.sep)
  6283. screen.save_tmp_png()
  6284. master_loop = False
  6285. playing = False
  6286. run = False
  6287. return('exit')
  6288. if ui == 'e':
  6289. test = False
  6290. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6291. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6292. test = True
  6293. else:
  6294. test = True
  6295. if test == True:
  6296. if player.inventory.materials.wood >= 5:
  6297. final_choice = 'Foo'
  6298. gc = screen.get_choice('What do you want to prodcuce?', ('Tool', 'Weapon', 'Armor','Jewelry'), True)
  6299. if gc == 0: #make a tool
  6300. items = (il.ilist['misc'][44], item_wear('axe',0,0), item_wear('pickaxe',0,0),il.ilist['misc'][14])
  6301. final_choice = screen.get_choice('What do you want to prodcuce exactly?', ('Torch','Axe','Pickaxe','Fishing rod'),True)
  6302. elif gc == 1: #make a weapon
  6303. 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))
  6304. class_choice = screen.get_choice('What do you want to prodcuce exactly?', ('Melee Weapon','Magic Weapon'), True)
  6305. if class_choice == 0:
  6306. ran = random.randint(0,99)
  6307. if player.skill.weapon_crafting == 'Novice':
  6308. if ran < 90:
  6309. final_choice = 0
  6310. else:
  6311. finnal_choice = 1
  6312. elif player.skill.weapon_crafting == 'Adept':
  6313. if ran < 10:
  6314. final_choice = 0
  6315. elif ran < 90:
  6316. final_choice = 1
  6317. else:
  6318. final_choice = 2
  6319. elif player.skill.weapon_crafting == 'Master':
  6320. if ran < 5:
  6321. final_choice = 0
  6322. elif ran < 15:
  6323. final_choice = 1
  6324. else:
  6325. final_choice = 2
  6326. else:
  6327. ran = random.randint(0,99)
  6328. if player.skill.weapon_crafting == 'Novice':
  6329. if ran < 90:
  6330. final_choice = 3
  6331. else:
  6332. finnal_choice = 4
  6333. elif player.skill.weapon_crafting == 'Adept':
  6334. if ran < 10:
  6335. final_choice = 3
  6336. elif ran < 90:
  6337. final_choice = 4
  6338. else:
  6339. final_choice = 5
  6340. elif player.skill.weapon_crafting == 'Master':
  6341. if ran < 5:
  6342. final_choice = 3
  6343. elif ran < 15:
  6344. final_choice = 4
  6345. else:
  6346. final_choice = 5
  6347. elif gc == 2: #make some armor
  6348. items = (item_wear('shoes',0,0), item_wear('cuisse',0,0), item_wear('helmet',0,0), item_wear('armor',0,0))
  6349. final_choice = screen.get_choice('What do you want to prodcuce exactly?', ('Shoes','Cuisse','Helmet','Armor'), True)
  6350. elif gc == 3:#make some jewlry
  6351. items = (item_wear('ring',0,0), item_wear('amulet',0,0), item_wear('necklace',0,0), item_wear('talisman',0,0))
  6352. final_choice = screen.get_choice('What do you want to prodcuce exactly?', ('Ring','Amulet','Necklace','Talisman'), True)
  6353. else:
  6354. final_choice = 'Foo'
  6355. choose = final_choice
  6356. try:
  6357. if choose != 'Foo':
  6358. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] == 0:
  6359. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] = container([items[choose]],False)
  6360. else:
  6361. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items.append(items[choose])
  6362. sfx.play('craft')
  6363. message_string = 'You produced a ' + items[choose].name + '.'
  6364. message.add(message_string)
  6365. if choose != 'Foo':
  6366. player.inventory.materials.wood -= 5
  6367. except:
  6368. None
  6369. run = False
  6370. else:
  6371. message.add('You do not have enough wood!')
  6372. run = False
  6373. elif ui == 'b':
  6374. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6375. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].inventory(False)
  6376. run = False
  6377. else:
  6378. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace.techID != tl.tlist['sanctuary'][0].techID:
  6379. #this wb dosen't stand inside the sanctuary
  6380. helpc = container([il.ilist['misc'][4]],True)
  6381. item_name = helpc.items[0].name
  6382. test_loot = helpc.loot(0)
  6383. run = False
  6384. if test_loot == True:
  6385. sfx.play('pickup')
  6386. string = '+[' + item_name + ']'
  6387. message.add(string)
  6388. 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
  6389. else:
  6390. message.add('This workbench seems to be attached to the floor.')
  6391. run = False
  6392. elif ui == 'x':
  6393. run = False
  6394. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'stonecutter':
  6395. #this is a stonecutter's workbench
  6396. run = True
  6397. first_call = True
  6398. while run:
  6399. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6400. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6401. screen.render_request('['+key_name['e']+'] - produce something (-10 Stone)', '['+key_name['b']+'] - take a produced item', '['+key_name['x']+'] - leave',first_call)
  6402. else:
  6403. screen.render_request('['+key_name['e']+'] - XXXXXXXXXXXX ', '['+key_name['b']+'] - take a produced item', '['+key_name['x']+'] - leave',first_call)
  6404. else:
  6405. screen.render_request('['+key_name['e']+'] - produce something (-10 Stone)', '['+key_name['b']+'] - pick up workbench', '['+key_name['x']+'] - leave',first_call)
  6406. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,0,mouse=game_options.mousepad)
  6407. first_call = False
  6408. if ui == 'exit':
  6409. exitgame = True
  6410. screen.render_load(5)
  6411. save(world,player,time,gods,save_path,os.sep)
  6412. screen.save_tmp_png()
  6413. master_loop = False
  6414. playing = False
  6415. run = False
  6416. return('exit')
  6417. if ui == 'e':
  6418. test = False
  6419. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6420. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6421. test = True
  6422. else:
  6423. test = True
  6424. if test == True:
  6425. if player.inventory.materials.stone >= 10:
  6426. gc = screen.get_choice('What do you want to produce?' ,('Functional Things', 'Decorative Things'), True)
  6427. if gc == 0: #make something functional
  6428. items = (il.ilist['misc'][0], il.ilist['misc'][8], il.ilist['misc'][9])
  6429. #items: fontain, furnace, altar
  6430. gc2 = screen.get_choice('What do you want to produce exactly?' ,('Fountain','Furnace','Altar'), True)
  6431. elif gc == 1:#make something decorative
  6432. items = (il.ilist['misc'][12],il.ilist['misc'][21],il.ilist['misc'][69])
  6433. #items: stone seat, pilar, throne
  6434. gc2 = screen.get_choice('What do you want to produce?' ,('Seat','Pilar','Throne'), True)
  6435. else:
  6436. return False
  6437. choose = gc2
  6438. try:
  6439. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] == 0:
  6440. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] = container([items[choose]],False)
  6441. else:
  6442. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items.append(items[choose])
  6443. sfx.play('craft')
  6444. message_string = 'You produced a ' + items[choose].name + '.'
  6445. message.add(message_string)
  6446. player.inventory.materials.stone -= 10
  6447. except:
  6448. None
  6449. run = False
  6450. else:
  6451. message.add('You do not have enough Stone!')
  6452. run = False
  6453. elif ui == 'b':
  6454. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6455. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].inventory(False)
  6456. run = False
  6457. else:
  6458. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace.techID != tl.tlist['sanctuary'][0].techID:
  6459. #this wb dosen't stand inside the sanctuary
  6460. helpc = container([il.ilist['misc'][5]],True)
  6461. item_name = helpc.items[0].name
  6462. test_loot = helpc.loot(0)
  6463. run = False
  6464. if test_loot == True:
  6465. sfx.play('pickup')
  6466. string = '+[' + item_name + ']'
  6467. message.add(string)
  6468. 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
  6469. else:
  6470. message.add('This workbench seems to be attached to the floor.')
  6471. run = False
  6472. elif ui == 'x':
  6473. run = False
  6474. 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':
  6475. #this is a forger's workbench or a master forge
  6476. run = True
  6477. first_call = True
  6478. while run:
  6479. price = 5
  6480. 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
  6481. price = 15
  6482. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6483. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6484. string = ('['+key_name['e']+'] - produce something (-' + str(price) + ' Ore)', '['+key_name['b']+'] - take a produced item', '['+key_name['x']+'] - leave',first_call)
  6485. screen.render_request(string[0],string[1],string[2])
  6486. else:
  6487. screen.render_request('['+key_name['e']+'] - XXXXXXXXXXXX ', '['+key_name['b']+'] - take a produced item', '['+key_name['x']+'] - leave',first_call)
  6488. else:
  6489. string = '['+key_name['e']+'] - produce something (-' + str(price) + ' Ore)', '['+key_name['b']+'] - pick up workbench', '['+key_name['x']+'] - leave'
  6490. screen.render_request(string[0],string[1],string[2],first_call)
  6491. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,0,mouse=game_options.mousepad)
  6492. first_call = False
  6493. if ui == 'exit':
  6494. exitgame = True
  6495. screen.render_load(5)
  6496. save(world,player,time,gods,save_path,os.sep)
  6497. screen.save_tmp_png()
  6498. master_loop = False
  6499. playing = False
  6500. run = False
  6501. return('exit')
  6502. if ui == 'e':
  6503. test = False
  6504. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6505. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6506. test = True
  6507. else:
  6508. test = True
  6509. if test == True:
  6510. if player.inventory.materials.ore >= price:
  6511. if player.skill.metallurgy == 'Novice':
  6512. material = random.randint(6,11)#tin to bronze
  6513. elif player.skill.metallurgy == 'Adept':
  6514. material = random.randint(11,18)#bronze to titan
  6515. elif player.skill.metallurgy == 'Master':
  6516. material = random.randint(18,20)#titan to magnicum
  6517. 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
  6518. material = 20 #magnicum only
  6519. final_choice = 'Foo'
  6520. gc = screen.get_choice('What do you want to procuce?', ('Tool', 'Weapon', 'Armor','Jewelry'), True)
  6521. if gc == 0: #make a tool
  6522. final_choice = screen.get_choice('What do you want to procuce exactly?', ('Axe', 'Pickaxe', 'Bucket'), True)
  6523. items = (item_wear('axe',material,0), item_wear('pickaxe',material,0), il.ilist['misc'][84])
  6524. elif gc == 1: #make a weapon
  6525. 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))
  6526. class_choice = screen.get_choice('What do you want to prodcuce?', ('Melee Weapon','Magic Weapon'), True)
  6527. if class_choice == 0:
  6528. ran = random.randint(0,99)
  6529. if player.skill.weapon_crafting == 'Novice':
  6530. if ran < 90:
  6531. final_choice = 0
  6532. else:
  6533. finnal_choice = 1
  6534. elif player.skill.weapon_crafting == 'Adept':
  6535. if ran < 10:
  6536. final_choice = 0
  6537. elif ran < 90:
  6538. final_choice = 1
  6539. else:
  6540. final_choice = 2
  6541. elif player.skill.weapon_crafting == 'Master':
  6542. if ran < 5:
  6543. final_choice = 0
  6544. elif ran < 15:
  6545. final_choice = 1
  6546. else:
  6547. final_choice = 2
  6548. else:
  6549. ran = random.randint(0,99)
  6550. if player.skill.weapon_crafting == 'Novice':
  6551. if ran < 90:
  6552. final_choice = 3
  6553. else:
  6554. finnal_choice = 4
  6555. elif player.skill.weapon_crafting == 'Adept':
  6556. if ran < 10:
  6557. final_choice = 3
  6558. elif ran < 90:
  6559. final_choice = 4
  6560. else:
  6561. final_choice = 5
  6562. elif player.skill.weapon_crafting == 'Master':
  6563. if ran < 5:
  6564. final_choice = 3
  6565. elif ran < 15:
  6566. final_choice = 4
  6567. else:
  6568. final_choice = 5
  6569. elif gc == 2: #make some armor
  6570. final_choice = screen.get_choice('What do you want to procuce exactly?', ('Shoes', 'Cuisse', 'Helmet', 'Armor'), True)
  6571. items = (item_wear('shoes',material,0), item_wear('cuisse',material,0), item_wear('helmet',material,0), item_wear('armor',material,0))
  6572. elif gc == 3:#make some jewelry
  6573. items = (item_wear('ring',material,0), item_wear('amulet',material,0), item_wear('necklace',material,0), item_wear('talisman',material,0))
  6574. final_choice = screen.get_choice('What do you want to prodcuce?', ('Ring','Amulet','Necklace','Talisman'), True)
  6575. else:
  6576. return False
  6577. choose = final_choice
  6578. try:
  6579. if choose != 'Foo':
  6580. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] == 0:
  6581. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] = container([items[choose]],False)
  6582. else:
  6583. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items.append(items[choose])
  6584. sfx.play('craft')
  6585. message_string = 'You produced a ' + items[choose].name + '.'
  6586. message.add(message_string)
  6587. if choose != 'Foo':
  6588. player.inventory.materials.ore -= price
  6589. except:
  6590. None
  6591. run = False
  6592. else:
  6593. message.add('You do not have enough ore!')
  6594. run = False
  6595. elif ui == 'b':
  6596. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6597. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].inventory(False)
  6598. run = False
  6599. else:
  6600. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace.techID != tl.tlist['sanctuary'][0].techID:
  6601. #this wb dosen't stand inside the sanctuary
  6602. helpc = container([il.ilist['misc'][6]],True)
  6603. item_name = helpc.items[0].name
  6604. test_loot = helpc.loot(0)
  6605. run = False
  6606. if test_loot == True:
  6607. sfx.play('pickup')
  6608. string = '+[' + item_name + ']'
  6609. message.add(string)
  6610. 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
  6611. else:
  6612. message.add('This workbench seems to be attached to the floor.')
  6613. run = False
  6614. elif ui == 'x':
  6615. run = False
  6616. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'alchemist':
  6617. #this is a alchemists's workshop
  6618. run = True
  6619. first_call = True
  6620. while run:
  6621. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6622. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6623. screen.render_request('['+key_name['e']+'] - brew a potion (-5 Herbs)', '['+key_name['b']+'] - take a potion', '['+key_name['x']+'] - leave',first_call)
  6624. else:
  6625. screen.render_request('['+key_name['e']+'] - XXXXXXXXXXXX ', '['+key_name['b']+'] - take a potion', '['+key_name['x']+'] - leave',first_call)
  6626. else:
  6627. screen.render_request('['+key_name['e']+'] - brew a potion (-5 Herbs)', '['+key_name['b']+'] - pick up workshop', '['+key_name['x']+'] - leave',first_call)
  6628. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,0,mouse=game_options.mousepad)
  6629. first_call = False
  6630. if ui == 'exit':
  6631. exitgame = True
  6632. screen.render_load(5)
  6633. save(world,player,time,gods,save_path,os.sep)
  6634. screen.save_tmp_png()
  6635. master_loop = False
  6636. playing = False
  6637. run = False
  6638. return('exit')
  6639. if ui == 'e':
  6640. test = False
  6641. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6642. if len(world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items) < 7:
  6643. test = True
  6644. else:
  6645. test = True
  6646. if test == True:
  6647. if player.inventory.materials.herb >= 5:
  6648. ordenary_potions = (il.ilist['food'][13],il.ilist['food'][14],il.ilist['food'][15],il.ilist['food'][16],il.ilist['food'][32])
  6649. #ordenary potions are: p.o. healing, p.o. feeding, p.o. refreshing, p.o. vitalising
  6650. 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])
  6651. #strong potions are: s.p.o. healing, s.p.o. feeding, s.p.o. refreshing, s.p.o. vitalising
  6652. upgrade_potions = (il.ilist['food'][21],il.ilist['food'][22],il.ilist['food'][23],il.ilist['food'][24],il.ilist['food'][35])
  6653. #upgrade potions are: p.o. hunger, p.o. thirst, p.o. tiredness, p.o. life
  6654. choose = random.randint(0,99)
  6655. if player.skill.alchemy == 'Novice':
  6656. if choose < 85: #make a ordenary potion(85%)
  6657. items = ordenary_potions
  6658. elif choose < 95:#make a strong potion(10%)
  6659. items = strong_potions
  6660. else:#make a upgrade potion(5%)
  6661. items = upgrade_potions
  6662. elif player.skill.alchemy == 'Adept':
  6663. if choose < 70: #make a ordenary potion(70%)
  6664. items = ordenary_potions
  6665. elif choose < 90:#make a strong potion(20%)
  6666. items = strong_potions
  6667. else:#make a upgrade potion(10%)
  6668. items = upgrade_potions
  6669. elif player.skill.alchemy == 'Master':
  6670. if choose < 50: #make a ordenary potion(50%)
  6671. items = ordenary_potions
  6672. elif choose < 80:#make a strong potion(30%)
  6673. items = strong_potions
  6674. else:#make a upgrade potion(20%)
  6675. items = upgrade_potions
  6676. choose = random.randint(0, len(items)-1)
  6677. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] == 0:
  6678. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] = container([items[choose]],False)
  6679. else:
  6680. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].items.append(items[choose])
  6681. sfx.play('alchemy')
  6682. message_string = 'You brewed a ' + items[choose].name + '.'
  6683. message.add(message_string)
  6684. player.inventory.materials.herb -= 5
  6685. run = False
  6686. else:
  6687. message.add('You do have not enough herbs!')
  6688. run = False
  6689. elif ui == 'b':
  6690. if world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]] != 0:
  6691. world.maplist[self.pos[2]][self.on_map].containers[self.pos[1]][self.pos[0]].inventory(False)
  6692. run = False
  6693. else:
  6694. if world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace.techID != tl.tlist['sanctuary'][0].techID:
  6695. #this ws dosen't stand inside the sanctuary
  6696. helpc = container([il.ilist['misc'][7]],True)
  6697. item_name = helpc.items[0].name
  6698. test_loot = helpc.loot(0)
  6699. run = False
  6700. if test_loot == True:
  6701. sfx.play('pickup')
  6702. string = '+[' + item_name + ']'
  6703. message.add(string)
  6704. 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
  6705. else:
  6706. message.add('This workshop seems to be attached to the floor.')
  6707. run = False
  6708. elif ui == 'x':
  6709. run = False
  6710. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'furnace':
  6711. #this is a furnace
  6712. run = True
  6713. first_call = True
  6714. while run:
  6715. screen.render_request('['+key_name['e']+'] - fire up the furnace (-10 wood)', ' ', '['+key_name['x']+'] - leave',first_call)
  6716. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,0,mouse=game_options.mousepad)
  6717. first_call = False
  6718. if ui == 'exit':
  6719. exitgame = True
  6720. screen.render_load(5)
  6721. save(world,player,time,gods,save_path,os.sep)
  6722. screen.save_tmp_png()
  6723. master_loop = False
  6724. playing = False
  6725. run = False
  6726. return('exit')
  6727. if ui == 'e':
  6728. if player.inventory.materials. wood >= 10:
  6729. sfx.play('flame')
  6730. message.add('You ligth up a fire.')
  6731. for i in range (0,len(player.inventory.food)):
  6732. if player.inventory.food[i] != player.inventory.nothing and player.inventory.food[i].rotten == False:
  6733. if player.inventory.food[i].techID == il.ilist['food'][4].techID: #this is a fish
  6734. message.add('You grill a fish.')
  6735. player.inventory.food[i] = deepcopy(il.ilist['food'][5])#turn a fish into a grilled fish
  6736. elif player.inventory.food[i].techID == il.ilist['food'][6].techID: #this are crops
  6737. message.add('You bake a bread.')
  6738. player.inventory.food[i] = deepcopy(il.ilist['food'][7])#turn crops into bread
  6739. elif player.inventory.food[i].techID == il.ilist['food'][7].techID: #this is a bread
  6740. message.add('You bake a bread for a second time.')
  6741. player.inventory.food[i] = deepcopy(il.ilist['food'][8])#turn a bread into rusk
  6742. elif player.inventory.food[i].techID == il.ilist['food'][9].techID: #this is raw meat
  6743. message.add('You grill raw meat.')
  6744. player.inventory.food[i] = deepcopy(il.ilist['food'][10])#turn raw meat into a grilled meat
  6745. elif player.inventory.food[i].techID == il.ilist['food'][11].techID: #this is a cult. mushroom
  6746. message.add('You grill a mushroom.')
  6747. player.inventory.food[i] = deepcopy(il.ilist['food'][12])#turn a cult. mushroom into a grilled mushroom
  6748. elif player.inventory.food[i].techID == il.ilist['food'][25].techID: #this is a jellyfish
  6749. message.add('You grill a jellyfish.')
  6750. player.inventory.food[i] = deepcopy(il.ilist['food'][26])#turn a jellyfish into a grilled jellyfish
  6751. elif player.inventory.food[i].techID == il.ilist['food'][0].techID: #this are red berries
  6752. message.add('You make some red jelly.')
  6753. player.inventory.food[i] = deepcopy(il.ilist['food'][29])#turn red berries into red jelly
  6754. elif player.inventory.food[i].techID == il.ilist['food'][27].techID: #this are blue berries
  6755. message.add('You make some blue jelly.')
  6756. player.inventory.food[i] = deepcopy(il.ilist['food'][30])#turn blue berries into blue jelly
  6757. elif player.inventory.food[i].techID == il.ilist['food'][28].techID: #this are red berries
  6758. message.add('You make some yellow jelly.')
  6759. player.inventory.food[i] = deepcopy(il.ilist['food'][31])#turn yellow berries into yellow jelly
  6760. elif player.inventory.food[i].techID == il.ilist['food'][38].techID: #this is corn
  6761. message.add('You make some popcorn.')
  6762. player.inventory.food[i] = deepcopy(il.ilist['food'][39])#turn corn into popcorn
  6763. elif player.inventory.food[i].techID == il.ilist['food'][40].techID: #this is an apple
  6764. message.add('You grill an apple.')
  6765. player.inventory.food[i] = deepcopy(il.ilist['food'][41])#turn apple into grilled apple
  6766. elif player.inventory.food[i].techID == il.ilist['food'][42].techID: #this is a golden apple
  6767. message.add('You grill a golden apple.')
  6768. player.inventory.food[i] = deepcopy(il.ilist['food'][43])#turn apple into grilled golden apple
  6769. ####add more here
  6770. run = False
  6771. else:
  6772. message.add('You do not have enough wood!')
  6773. run = False
  6774. elif ui == 'x':
  6775. run = False
  6776. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'altar':
  6777. #this is a altar
  6778. run = True
  6779. first_call = True
  6780. while run:
  6781. if player.difficulty == 0 or player.difficulty == 4: #playing on easy or sandbox
  6782. if gods.judgement() == True:
  6783. pray_string = '['+key_name['e']+'] - pray (save)'
  6784. else:
  6785. pray_string = '['+key_name['e']+'] - pray (not save)'
  6786. else:
  6787. pray_string = '['+key_name['e']+'] - pray'
  6788. screen.render_request(pray_string, '['+key_name['b']+'] - identify ', '['+key_name['x']+'] - leave',first_call)
  6789. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,0,mouse=game_options.mousepad)
  6790. first_call = False
  6791. if ui == 'exit':
  6792. exitgame = True
  6793. screen.render_load(5)
  6794. save(world,player,time,gods,save_path,os.sep)
  6795. screen.save_tmp_png()
  6796. master_loop = False
  6797. playing = False
  6798. run = False
  6799. return('exit')
  6800. if ui == 'e':
  6801. judgement = gods.judgement() # see if the player is supported by the gods
  6802. if judgement == True:
  6803. cursed_items = 0
  6804. bodyparts = ('Hold(R)', 'Hold(L)', 'Head', 'Body', 'Legs', 'Feet', 'Hand', 'Neck', 'Axe', 'Pickaxe')
  6805. for i in bodyparts:#check if player wears some cursed equipment
  6806. if player.inventory.wearing[i].cursed < 1 and i != player.inventory.nothing:
  6807. cursed_items += 1
  6808. if (player.lp*100)/player.attribute.max_lp < 20:#player has less then 20% of lp -> heal
  6809. player.lp = player.attribute.max_lp
  6810. message.add('The gods heal your wounds.')
  6811. gods.mood -= 10
  6812. run = False
  6813. 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:
  6814. #player is very hungry,thirsty or tired -> refresh
  6815. player.attribute.hunger = player.attribute.hunger_max
  6816. player.attribute.thirst = player.attribute.thirst_max
  6817. player.attribute.tiredness = player.attribute.tiredness_max
  6818. message.add('The gods rerfresh you.')
  6819. gods.mood -= 10
  6820. run = False
  6821. elif cursed_items > 0:#player has some cursed items
  6822. bodyparts = ('Hold(R)', 'Hold(L)', 'Head', 'Body', 'Legs', 'Feet', 'Hand', 'Neck', 'Axe', 'Pickaxe')
  6823. for j in bodyparts:
  6824. if player.inventory.wearing[j].cursed < 1 and player.inventory.wearing[j] != player.inventory.nothing:
  6825. 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)
  6826. player.inventory.wearing[j] = item
  6827. message.add('The gods remove curses from your equipment.')
  6828. gods.mood -= 10
  6829. run = False
  6830. else:
  6831. message.add('The gods are pleased about you.')
  6832. run = False
  6833. else:
  6834. uncursed_items = 0
  6835. bodyparts = ('Hold(R)', 'Hold(L)', 'Head', 'Body', 'Legs', 'Feet', 'Hand', 'Neck','Axe','Pickaxe')
  6836. for i in bodyparts:#check if player wears some cursed equipment
  6837. if player.inventory.wearing[i].cursed > 0 and player.inventory.wearing[i] != player.inventory.nothing:
  6838. uncursed_items += 1
  6839. if uncursed_items > 0:
  6840. for j in bodyparts:
  6841. if player.inventory.wearing[j].cursed > 0 and player.inventory.wearing[j] != player.inventory.nothing:
  6842. 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)
  6843. player.inventory.wearing[j] = item
  6844. message.add('The gods are angry and curse your equipment.')
  6845. run = False
  6846. else:
  6847. player.lp -= 5
  6848. message.add('The gods are angry and hurt you')
  6849. run = False
  6850. elif ui == 'b':
  6851. if gods.judgement() == True:
  6852. num_ident = 0
  6853. bodyparts = ('Hold(R)', 'Hold(L)', 'Head', 'Body', 'Legs', 'Feet', 'Hand', 'Neck', 'Axe', 'Pickaxe')
  6854. for i in bodyparts:
  6855. if player.inventory.wearing[i] != player.inventory.nothing and player.inventory.wearing[i].known == False:
  6856. player.inventory.wearing[i].identification()
  6857. num_ident += 1
  6858. for j in range (0, len(player.inventory.equipment)):
  6859. if player.inventory.equipment[j] != player.inventory.nothing and player.inventory.equipment[j].known == False:
  6860. player.inventory.equipment[j].identification()
  6861. num_ident += 1
  6862. if num_ident > 0:
  6863. message.add('Now you are aware of your equipments attributes.')
  6864. gods.mood -= num_ident
  6865. else:
  6866. message.add('You have nothing that could be identified.')
  6867. run = False
  6868. else:
  6869. message.add('The gods deny to identify your equipment!')
  6870. run = False
  6871. elif ui == 'x':
  6872. run = False
  6873. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'activate_portal':
  6874. 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)'
  6875. 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]:
  6876. a_string = '['+key_name['e']+'] - activate'
  6877. activate = True
  6878. else:
  6879. a_string = ' '
  6880. activate = False
  6881. l_string = '['+key_name['x']+'] - leave'
  6882. screen.render_request(head_string,a_string,l_string)
  6883. run = True
  6884. while run:
  6885. ui = getch(screen.displayx,screen.displayy,game_options.sfxmode,game_options.turnmode,mouse=game_options.mousepad)
  6886. if ui == 'exit':
  6887. exitgame = True
  6888. screen.render_load(5)
  6889. save(world,player,time,gods,save_path,os.sep)
  6890. screen.save_tmp_png()
  6891. master_loop = False
  6892. playing = False
  6893. run = False
  6894. return('exit')
  6895. if ui == 'e' and activate == True:
  6896. player.inventory.materials.gem -= world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].conected_resources[1]
  6897. if player.inventory.materials.gem < 0:#only to be sure
  6898. player.inventory.materials.gem = 0#
  6899. replace = deepcopy(world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace)
  6900. 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]])
  6901. world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].replace = replace
  6902. sfx.play('portal')
  6903. run = False
  6904. if ui == 'x':
  6905. run = False
  6906. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'go_grassland':
  6907. screen.render_fade(True,False)
  6908. try:
  6909. pos = world.maplist[0]['local_0_0'].find_first(tl.tlist['portal'][8])
  6910. except:
  6911. test = False
  6912. while test == False:
  6913. test = world.elfish_generator(0)
  6914. pos = world.maplist[0]['local_0_0'].find_first(tl.tlist['portal'][8])
  6915. player.pos[0] = pos[0]
  6916. player.pos[1] = pos[1]
  6917. player.pos[2] = 0#only to be sure
  6918. player.on_map = 'local_0_0'
  6919. player.stand_check()
  6920. sfx.play('portal')
  6921. screen.render_fade(False,True)
  6922. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'return_grassland':
  6923. pos = world.maplist[self.pos[2]]['elysium_0_0'].find_first(tl.tlist['portal'][7])
  6924. screen.render_fade(True,False)
  6925. player.pos[0] = pos[0]
  6926. player.pos[1] = pos[1]
  6927. player.pos[2] = 0#only to be sure
  6928. player.on_map = 'elysium_0_0'
  6929. player.stand_check()
  6930. sfx.play('portal')
  6931. screen.render_fade(False,True)
  6932. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'go_fortress':
  6933. screen.render_fade(True,False)
  6934. try:
  6935. pos = world.maplist[0]['fortress_0_0'].find_first(tl.tlist['portal'][2])
  6936. except:
  6937. test = False
  6938. while test == False:
  6939. test = world.elfish_generator(0)
  6940. pos = world.maplist[0]['fortress_0_0'].find_first(tl.tlist['portal'][2])
  6941. player.pos[0] = pos[0]
  6942. player.pos[1] = pos[1]
  6943. player.pos[2] = 0#only to be sure
  6944. player.on_map = 'fortress_0_0'
  6945. player.stand_check()
  6946. sfx.play('portal')
  6947. screen.render_fade(False,True)
  6948. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'return_fortress':
  6949. pos = world.maplist[self.pos[2]]['elysium_0_0'].find_first(tl.tlist['portal'][1])
  6950. screen.render_fade(True,False)
  6951. player.pos[0] = pos[0]
  6952. player.pos[1] = pos[1]
  6953. player.pos[2] = 0#only to be sure
  6954. player.on_map = 'elysium_0_0'
  6955. player.stand_check()
  6956. sfx.play('portal')
  6957. screen.render_fade(False,True)
  6958. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'go_desert':
  6959. screen.render_fade(True,False)
  6960. try:
  6961. pos = world.maplist[self.pos[2]]['desert_0_0'].find_first(tl.tlist['portal'][5])
  6962. except:
  6963. world.desert_generator(20)
  6964. world.cave_generator(5,'desert')
  6965. world.border_generator(6,'desert')
  6966. pos = world.maplist[self.pos[2]]['desert_0_0'].find_first(tl.tlist['portal'][5])
  6967. player.pos[0] = pos[0]
  6968. player.pos[1] = pos[1]
  6969. player.pos[2] = 0#only to be sure
  6970. player.on_map = 'desert_0_0'
  6971. player.stand_check()
  6972. screen.render_fade(False,True)
  6973. elif world.maplist[self.pos[2]][self.on_map].tilemap[self.pos[1]][self.pos[0]].use_group == 'return_desert':
  6974. pos = world.maplist[self.pos[2]]['elysium_0_0'].find_first(tl.tlist['portal'][4])
  6975. screen.render_fade(True,False)