anew don.df

"load boot.df" to eval-buf

"../deathforth/don/donroomdef.txt" $load-rooms
// "../deathforth/don/donindustry.txt" $load-rooms
// "../deathforth/don/donunderg.txt" $load-rooms
// "../deathforth/don/donspecial.txt" $load-rooms

: empty depth remove ;

: sc player .charid@ #character .specialtype! ;

: box
	spawn
	0x 4 themed spriteid!
	bbox
	openable container
	as-cloth
;

: ebox box opened noloot ;
: edrawers drawers opened noloot ;
: esmallshelf smallshelf opened noloot  ;
: ebigshelf bigshelf opened noloot  ;
: ecupboard cupboard opened noloot ;
: efridge fridge opened noloot ;

: erndbox 1 4 rnd case 1 of ebox endof 2 of esmallshelf endof 3 of ebigshelf endof 4 of edrawers endof endcase ;

: stall
	spawn
	0x 1e themed spriteid!
	bbox immovable
;

: diningset
	table
	75 %chance if chair -1 movey drift then
	75 %chance if chair 1 movey drift then
	50 %chance if chair -1 movex drift then
	50 %chance if chair 1 movex drift then
;

: dbasement UP column-door "bathroom" with-door ;

: uzi WEAPON_UZI weapon ;
: shotgun WEAPON_SHOTGUN weapon ;
: rifle WEAPON_RIFLE weapon ;
: revolver WEAPON_REVOLVER weapon ;
: pistol WEAPON_PISTOL weapon ;
: ak47 WEAPON_AK47 weapon ;
: cleaver WEAPON_CLEAVER weapon ;
: wrench WEAPON_WRENCH weapon ;
: maul WEAPON_MAUL weapon ;
: nailboard WEAPON_NAIL_BOARD weapon ;
: bat WEAPON_BAT weapon ;
: blowtorch WEAPON_BLOWTORCH weapon ;
: hatchet WEAPON_HATCHET weapon ;
: spatula WEAPON_SPATULA weapon ;
: chainsaw WEAPON_CHAINSAW weapon ;
: houseknife WEAPON_KITCHEN_KNIFE weapon ;

: spawnscat spawnloot scatter ;
: skelscat skel scatter ;

: sbullet LOOT_BULLET spawnscat ;
: sshot LOOT_SHOTGUN_SHELL spawnscat ;
: srifle LOOT_RIFLE_SHELL spawnscat ;
: sgas LOOT_GAS spawnscat ; 

: meleeweapons 1 4 rnd case 1 of 90 %chance if nailboard else chainsaw then endof 2 of 50 %chance if cleaver else houseknife then endof
3 of 25 %chance if maul else bat then endof 4 of 50 %chance if hatchet else wrench then endof endcase ;

: commonranged
1 2 rnd case
1 of 95 %chance if pistol 15 sbullet else 50 %chance if uzi 40 sbullet else ak47 30 srifle then then endof
2 of 50 %chance if revolver 12 sbullet else 50 %chance if rifle 15 srifle else shotgun 8 sshot then then endof
endcase ;

: niceranged
1 2 rnd case
1 of commonranged endof
2 of 20 %chance if ak47 30 srifle else 50 %chance if uzi 40 sbullet else shotgun 8 sshot then then endof
endcase ;

: exoticweapons 50 %chance if chainsaw 200 sgas else blowtorch 50 sgas then ;
: niceweapons 30 %chance if meleeweapons else 30 %chance if commonranged else 90 %chance if niceranged else exoticweapons then then then ;
: kitchenweapons 2 %chance if blowtorch 50 sgas else 70 %chance if houseknife else spatula then then ;
: cheapweapons 60 %chance if meleeweapons else 50 %chance if commonranged else 50 %chance if niceweapons else kitchenweapons then then then ;
 
: batme WEAPON_BAT 1 #character .weapona! ;
: cleaverme WEAPON_CLEAVER 1 #character .weapona! ;
: gunme WEAPON_PISTOL 1 #character .weapona! 30 LOOT_BULLET 1 #character .lootamt! ;

: maulme WEAPON_MAUL 1 #character .weaponb! ;
: chainme WEAPON_CHAINSAW 1 #character .weaponb! 500 LOOT_GAS 1 #character .lootamt! ;
: shotme WEAPON_SHOTGUN 1 #character .weaponb! 20 LOOT_SHOTGUN_SHELL 1 #character .lootamt! ;

: hsmalltable spawn 0x 10 themed spriteid! rndflip bbox as-wood ;

: dkitchen random-door "kitchen" with-door ;
: dbathroom random-door "bathroom" only-with-door empty ;
: dhall random-door "hall" with-door empty ;
: dliving random-door "living" with-door ;
: dcloset random-door "closet" only-with-door empty ;
: beddoor 50 %chance if dcloset then 50 %chance if dbathroom then ;
: dnapt n edge-inc n random-door "bedroom" with-door empty ;
: dwrand w edge-inc w random-door empty ;
: derand e edge-inc e random-inset-door empty ;
	
: flippy rndsign dup -1 * ;	

// LOOSE LOOT

// FILL IN LLWEIRD AND LLTHROW LATER
: LLweird 5 for skeldog scatter next ;
: LLthrow endtable scatter ;
: LLmiscdrop 60 %chance if 50 100 rnd LOOT_GAS spawnscat else 60 %chance if 1 LOOT_FOOD spawnscat else 1 LOOT_MEDICAL spawnscat then then ;
: LLmiscmulti skelscat 2 for LLmiscdrop next 20 %chance if LLmiscdrop then ;
: LLmischeaps skelscat 3 for LLmiscdrop 10 %chance if LLmiscdrop skelscat then next ;
: LLmisc 70 %chance if LLmiscdrop else 90 %chance if LLmiscmulti else LLmischeaps then then ;
: LLkitchen 1 LOOT_FOOD spawnscat 2 for 20 %chance if skelscat 1 LOOT_FOOD spawnscat then next ;
: LLammobox 40 %chance if 3 11 rnd LOOT_BULLET spawnscat else 50 %chance if 2 9 rnd LOOT_RIFLE_SHELL spawnscat else 1 7 rnd LOOT_SHOTGUN_SHELL spawnscat then then ;
: LLammomulti skelscat 2 for LLammobox next 30 %chance if LLammobox then ;
: LLammoheaps skelscat 3 for LLammobox 20 %chance if LLammobox skelscat then next ;
: LLammo 70 %chance if LLammobox else 90 %chance if LLammomulti else LLammoheaps then then ;
: looseloot 40 %chance if LLammo else 66 %chance if LLmisc else 50 %chance if LLthrow else LLweird then then then ;
	
roomgen{

: bathrndloot 1 LOOT_MEDICAL loot! amount! ;
: bathlootf 50 %chance if cupboard bathrndloot else drawers bathrndloot then ;
: bathloote 50 %chance if ecupboard else edrawers then ;
: bathloot 50 %chance if bathlootf else bathloote then ;

: toiletloot 80 %chance if 1 LOOT_BULLET else 1 LOOT_GAS then loot! amount! ;
: bathtoilet 20 %chance if toilet toiletloot else spawn 0x 1b themed spriteid! bbox immovable 25 health! then ;

: bathset
	only-chosen; bathtoilet
	sink -1 1 rnd movex
;

: nbathset
	only-chosen;
	sink -10 movey
	flippy
	bathtub drift -10 movey 10 * movex
	bathtoilet drift -10 movey 10 * movex
	80 %chance if bathloot drift -10 movey then
;

: nbathsetsmall
	only-chosen;
	sink -10 movey
	flippy
	bathtoilet drift -10 movey 10 * movex
	25 %chance if bathloot else bathtub then drift -10 movey 10 * movex
;

: nbathsettiny
	only-chosen;
	sink -10 movey
	flippy
	bathtoilet drift -10 movey 10 * movex
;

: rndhshelf
only-chosen;
40 %chance if smallshelf exit then
40 %chance if bigshelf exit then
60 %chance if drawers exit then 
;

: hallset
	only-chosen;
	1 7 rnd case
	1 of 25 %chance if skel drift then 33 %chance if cheapweapons drift then 50 %chance if chair scatter then 70 %chance if endtable scatter then empty endof
	2 of chair scatter chair scatter 50 %chance if chair then endof
	3 of smalltable endof
	4 of rnd5050 chair endof
	5 of drawers endof
	6 of 50 %chance if box then endof
	7 of 50 %chance if chair then 20 %chance if cheapweapons then endof	endcase
	20 %chance if looseloot then
;

// DEATH AND TREASURE AND CLOSETS

: closetloot 50 %chance if LLammobox else LLmiscdrop then ;
: closetset 0 1 rnd zombs 50 %chance if closetloot then ;

: ammodumploot 40 %chance if 12 20 rnd LOOT_BULLET else 50 %chance if 11 18 rnd LOOT_RIFLE_SHELL else 6 15 rnd LOOT_SHOTGUN_SHELL then then loot! amount! ;
: rndloot
	1 4 rnd case
	1 of rndhshelf endof
	2 of box endof
	3 of 75 %chance if cupboard then endof
	4 of 75 %chance if drawers then endof
	endcase
;

: rnddanger
	1 3 rnd case
	1 of skel endof
	2 of skeldog endof
	3 of 20 %chance if box then endof
	endcase
;

: DRhoarder skel drift bed drift LLmiscdrop 60 %chance if cheapweapons drift then 3 for 50 %chance if box drift then next ;
: DRstandoff 3 for 50 %chance if skel drift then next 2 for 30 %chance if niceweapons drift then next ;
: DRtonskele 4 for 50 %chance if skel scatter then next 2 for 20 %chance if skeldog scatter then next ;
: DRdeco 30 %chance if DRhoarder else 40 %chance if DRstandoff else DRtonskele then then ;

: DRammodump box ammodumploot LLammo drift 2 for 60 %chance if box ammodumploot scatter then next ;
: DRboxscat box scatter 2 for 60 %chance if box scatter LLmiscdrop then next ;
: DRboxes 50 %chance if DRboxscat else DRammodump then ;
: DRtriloot rndloot rndloot -1 movex rndloot 1 movex looseloot ;
: DRloot 0 2 rnd zombs 30 %chance if niceweapons drift else 40 %chance if DRtriloot else 90 %chance if DRboxes else exoticweapons then then then ;

: DRzomb 40 %chance if 10 %zombs exit then 20 %chance if 20 %zombs exit then 20 %chance if 30 %zombs exit then 20 %chance if 50 %zombs exit then 5 %chance if 100 %zombs exit then empty ;
: deathroom only-chosen; 2 4 rnd zombs DRzomb 50 %chance if DRloot then DRdeco ;
: lootroom only-chosen; 30 %chance if DRzomb then DRloot DRdeco ;


// LIVINGROOM STUFF

: livingdeco 1 4 rnd case 1 of lazyboy endof 2 of 20 %chance if drawers else lazyboy then endof 3 of endtable endof 4 of 50 %chance if lazyboy then endof endcase ;
: ldecopair livingdeco 1 movex dup movey 30 %chance if drift then livingdeco -1 movex dup movey 30 %chance if drift then ;
: ldecopairdrift livingdeco 1 movex dup movey drift livingdeco -1 movex dup movey drift ;

: nlivingset
	only-chosen;
	couch -10 movey
	flippy
	30 %chance if rndhshelf -10 movey 10 * movex then
	50 %chance if livingdeco -10 movey 10 * movex then
	80 %chance if 50 %chance if endtable else smalltable then -10 movey drift then empty
;

: rndliving
	only-chosen;
	1 5 rnd case
	1 of box endof
	2 of skel endof
	3 of 60 %chance if rndhshelf then endof
	4 of cheapweapons endof
	5 of livingdeco endof
	endcase
;

: lcouchend 80 %chance if endtable drift then couch -1 movey -1 1 rnd movex 80 %chance if lazyboy 1 movey -1 1 rnd movex then 20 %chance if box scatter then ;
: lskelechair chair drift skel scatter 50 %chance if skel scatter then cheapweapons scatter chair drift 40 %chance if chair drift then ;
: lcouchdeco couch drift 25 %chance if box drift then livingdeco -2 2 rnd movex 60 %chance if endtable then ;
: lendlazy endtable flippy lazyboy 1.5 * movex 80 %chance if lazyboy 1.5 * movex then 25 %chance if box scatter then ;
: llazyloot 25 %chance if 50 %chance if rndhshelf scatter -5 movey else cheapweapons scatter then then lazyboy 1 movex drift lazyboy -1 movex drift 70 %chance if endtable then ;
: lcouchtable1 flippy hsmalltable 1 movey couch -1 movey livingdeco -0.5 movey 2 * movex 40 %chance if livingdeco -0.5 movey 2 * movex then ;
: lcouchtable2 flippy 50 %chance if couch else livingdeco then -1.5 movey hsmalltable lazyboy 1 * movex 1.3 movey 60 %chance if lazyboy 1 * movex 1.3 movey then ;
: lcouchends couch -1 movey hsmalltable 1 movey 60 %chance if endtable -1.5 movex -1 movey then 60 %chance if endtable 1.5 movex -1 movey then 60 %chance if livingdeco -1.5 movex 0.9 movey then 60 %chance if livingdeco 1.5 movex 0.9 movey then ;
: ltrideco flippy livingdeco 1 * movey ldecopair empty ;
: l4decos livingdeco -1 movex -1 movey drift livingdeco 1 movex -1 movey drift livingdeco 1 movex 1 movey drift livingdeco -1 movex 1 movey drift ;
: llazypair 40 %chance if couch else 50 %chance if rndhshelf else hsmalltable then then -1 movey lazyboy -1 movex 1 movey lazyboy 1 movex 1 movey ;

: livingsets
	only-chosen;
	llazypair
;

: livingset
	only-chosen;
	1 11 rnd case
	1 of lcouchend endof
	2 of lskelechair endof
	3 of lcouchdeco endof
	4 of lendlazy endof
	5 of llazyloot endof
	6 of lcouchtable1 endof
	7 of lcouchends endof
	8 of l4decos endof
	9 of ltrideco endof
	10 of llazypair endof
	11 of lcouchtable2 endof endcase
	20 %chance if looseloot then
;

// KITCHEN KORNER

: krndloot 1 2 rnd LOOT_FOOD loot! amount! ;
: klootf 50 %chance if cupboard krndloot else 50 %chance if smallshelf krndloot else bigshelf then then ;
: kloote 50 %chance if ecupboard else 50 %chance if esmallshelf else ebigshelf then then ;
: kloot 50 %chance if klootf else kloote then ;
: stoveloot 50 %chance if 5 10 rnd LOOT_GAS else 1 LOOT_FOOD then loot! amount! ;

: KLzomb 1 6 rnd zombs 2 for 60 %chance if skel scatter then next 80 %chance if kitchenweapons drift then ;
: KLdouble kitchenweapons drift 40 %chance if kitchenweapons scatter then 20 %chance skeldog drift ;
: KLbonus kitchenweapons drift box scatter ;
: KLtonskele 4 for 50 %chance if skel scatter then next 2 for 20 %chance if skeldog scatter then next ;
: KLroll 0 3 rnd zombs 30 %chance if KLbonus else 40 %chance if KLdouble else 50 %chance if KLzomb else KLtonskele then then then ;
: KLchance 50 %chance if KLroll then 50 %chance if LLkitchen then ;

: kstove 40 %chance if stove stoveloot else spawn 0x 21 themed spriteid! bbox immovable 25 health! then ;
: kfridge 60 %chance if fridge krndloot else efridge then ;
: kcounterpair 50 %chance if kitchensink -1 movex dup movey kstove 1 movex dup movey else kitchensink 1 movex dup movey stove -1 movex dup movey then ;
: onlyfridge only-chosen; kfridge ;

: fridgespread
	only-chosen;
	70 %chance if smalltable drift then
	flippy kfridge 2 * movex
	70 %chance if kloot 2 * movex then empty
;

: kcounter 50 %chance if kitchensink -1 movex -1 movey kstove 1 movex -1 movey else kitchensink 1 movex -1 movey kstove -1 movex -1 movey then ;

: rndkitchen
only-chosen;
40 %chance if diningset exit then
40 %chance if smalltable exit then
30 %chance if kloot exit then
;

: kitchensethalf
	only-chosen;
	kitchensink -10 movey
	flippy 80 %chance if kloot -10 movey 10 * movex then kstove -10 movey 10 * movex
	empty KLchance
;

: nkitchensettiny
	only-chosen;
	flippy
	kfridge -10 movey 10 * movex
    kitchensink -10 movey 10 * movex KLchance
;

: nkitchenset
	only-chosen;
	kcounter flippy
	kfridge -10 movey 3 * movex
	80 %chance if kloot -10 movey 3 * movex then empty KLchance
;

: kitchencentral
	only-chosen;
	flippy kfridge 1 * movey kcounterpair empty KLchance
;

// BEDROOM STUFF

: beddeco 1 4 rnd case 1 of box endof 2 of lazyboy endof 3 of endtable endof 4 of chair endof endcase ;
: rndbed only-chosen; 60 %chance if beddeco else box -1 1 rnd movex then ;
: beddecopair beddeco 1 movex dup movey beddeco -1 movex dup movey ;
: rndhshelfflip rndhshelf 1 * movex -1 movey ;

: bsidedrawers flippy bed drawers 1 * movex 30 %chance if drawers 1 * movex then ;
: bsidedrawersV flippy bed 1 movey drawers 1 * movex -1 movey 30 %chance if drawers 1 * movex -1 movey then ;
: bsidedrawersS bed -0.6 movey drawers 0.6 movey ;
: bsiderndshelf bed 1 movey flippy rndhshelfflip 20 %chance if rndhshelfflip then empty ;
: bsidechaos1 2 for skel scatter next bed drift ebox drift ;
: bsidechaos2 3 for 50 %chance if skel scatter then next bed 1 movey drift erndbox -1 movey drift 50 %chance if erndbox -1 movey drift then ;
: beddecosV flippy bed 1 * movey beddecopair empty ; 
: randbedndecos	mrand dup 4corners bed movex movey 1+ dup 4corners beddeco movex movey 1+ dup 4corners beddeco movex movey 1+ 4corners beddeco movex movey ;
: beddecostwin flippy bed beddeco -1.5 1.5 rnd movey 1.8 * movex beddeco -1.5 1.5 rnd movey 1.8 * movex ;

: BLzomb 1 6 rnd zombs 2 for 60 %chance if skel scatter then next 40 %chance if niceweapons drift then ;
: BLdouble cheapweapons drift 40 %chance if cheapweapons scatter then 20 %chance skeldog drift ;
: BLbonus cheapweapons drift box scatter ;
: BLtonskele 4 for 50 %chance if skel scatter then next 2 for 20 %chance if skeldog scatter then next ;
: bedloot 0 3 rnd zombs 30 %chance if BLbonus else 40 %chance if BLdouble else 50 %chance if BLzomb else BLtonskele then then then ;

( : bedset only-chosen; bsiderndshelf ; )

: bedset
	only-chosen; 1 10 rnd case
	1 of bsidedrawers endof
	2 of bsidedrawersV endof
	3 of bsidedrawersS endof
	4 of bsiderndshelf endof
	5 of bsidechaos1 endof
	6 of bsidechaos2 endof
	7 of beddecosV endof
	8 of randbedndecos endof
	9 of randbednchairs endof
	10 of beddecostwin endof endcase
	20 %chance if bedloot then
	40 %chance if looseloot then
;

: nbedset
	only-chosen;
	bed -10 movey
	flippy
	endtable drift -10 movey 10 * movex
	drawers drift -10 movey 10 * movex
	40 %chance if looseloot then
;

}

\ MOTD Loading

// load? don/motd.df

\ Load different locations depending on what we want people to test

// load? don/closettestregion.df
// load? don/closettestlocation.df
// load? don/city-regions.df
// load? don/city-locations.df
// load? don/don-regions.df
// load? don/don-locations.df
 load? don/test-regions.df
// load? don/kitchentest-locations.df
 load? don/bedtest-locations.df
// load? don/industry-regions.df
// load? don/industry-locations.df
// load? don/underg-regions.df
// load? don/underg-locations.df
// load? don/special-regions.df
// load? don/special-locations.df

\ MORE LOADING

// load? don/cyoatest/cyoatest.df
// load? don/cyoa/cyoaroadf1.df
// load? don/cyoa/cyoaroadf2.df
