Function to change level parameters in zone.lua

Moderator: Moderator

Post Reply
Message
Author
Zonk
Sher'Tul
Posts: 1067
Joined: Sat Mar 01, 2003 4:01 pm

Function to change level parameters in zone.lua

#1 Post by Zonk »

One can use the 'levels' field in zone.lua to have the levels of a zone use different sizes, layouts, generators...

This is quite useful, but what if one wanted to create a very deep zone where each level changed followed a pattern/function?

For example, making a dungeon smaller or larger with each level or alternating level layouts/map generators,
Doing this manually for a large amount of levels is possible, but frustrating.

So I'm asking for 'width' and 'height'(and other fields where it makes sense) to allow functions, and also for a way to change the generators/other properties of specific level using a function. In both cases of course level would be a required argument...

For example, say I wanted every even level of my zone to have no NPCs, then I could use...

Code: Select all

adjust_level = function(zone, level) if level % 2 == 0 then zone.generator.actor.nb_npc = {0,0} end
...
(this is of course pseudocode, it shouldn't actually alter the zone but only the parameters for the level to be generated)
Last edited by Zonk on Tue Jun 11, 2013 6:51 pm, edited 1 time in total.
ToME online profile: http://te4.org/users/zonk
Addons (most likely obsolete): Wights, Trolls, Starting prodigy, Alternate save/resistance system

Hachem_Muche
Uruivellas
Posts: 744
Joined: Thu Nov 18, 2010 6:42 pm

Re: Function to change level parameters in zone.lua

#2 Post by Hachem_Muche »

I agree, this would be a nice feature.

In the meantime, I've put in code to make level by level adjustments for Infinite500 via the on_setup (called when the zone is loaded) and on_leave (called when leaving each level) functions in the zone definition table:

Code: Select all

on_setup = function(self)
		self.width = 50 + rng.range(0,40)
		self.height = math.ceil(4900/self.width)
		self:updateBaseLevel()
		self.generator.map.rooms = {"random_room", {"pit",3}, {"greater_vault",5 + 4*self.base_level/(self.base_level+15)}} --I5 more vaults at higher player levels
	end,

Code: Select all

on_leave = function(lev, old_lev, newzone)
		--set up for next level generation
		game.zone.width = 50 + rng.range(0,40)
		game.zone.height = math.ceil(4900/game.zone.width)
		game.zone.generator.map.rooms = {"random_room", {"pit",3}, {"greater_vault",5 + 4*game.zone.base_level/(game.zone.base_level+15)}} --I5 more vaults at higher levels
	end,
It's a little bit of a kludge, but I don't see any reason you couldn't specify a completely new generator table for each level. (Perhaps just randomly pick from a list of generator specs, for example.)
Author of the Infinite 500 and PlenumTooltip addons, and the joys of Scaling in ToME.

darkgod
Master of Eyal
Posts: 10747
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Function to change level parameters in zone.lua

#3 Post by darkgod »

[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Zonk
Sher'Tul
Posts: 1067
Joined: Sat Mar 01, 2003 4:01 pm

Re: Function to change level parameters in zone.lua

#4 Post by Zonk »

That was fast, thanks :)
ToME online profile: http://te4.org/users/zonk
Addons (most likely obsolete): Wights, Trolls, Starting prodigy, Alternate save/resistance system

darkgod
Master of Eyal
Posts: 10747
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Function to change level parameters in zone.lua

#5 Post by darkgod »

[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Post Reply