quick question

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
marchewka
Thalore
Posts: 156
Joined: Thu Dec 30, 2010 9:52 am

quick question

#1 Post by marchewka »

Repeating the question from Vault theme in Ideas thread - I'd be much obliged if someone provided me with 1 line examples of the following, needed for creation of new vaults:

1# How to create floor tile that contains item OR monster OR trap?

2# Similarly - how to create a tile that produces an item with some % chance?

3# How to create newEntity that does something randomly (say, swaps between two possible shadersr with 1/4 chance each game turn)

Sharzyl
Wayist
Posts: 23
Joined: Sun Jan 15, 2012 9:52 am

Re: quick question

#2 Post by Sharzyl »

#1 and #2, you may want to check the Last Hope graveyard.
If you open a coffin, there's a chance to get treasure or monster.
If you want a tile, you want to check alarm trap that can summon enemy units, it's pretty common in Assassin Lord's hideout.

Not really understand about #3.

marchewka
Thalore
Posts: 156
Joined: Thu Dec 30, 2010 9:52 am

Re: quick question

#3 Post by marchewka »

Thx for the answer. Checking the first two in the code. Regarding #3 - say i want to make a floor with shifting shadows, a tile that has 1/4 chance each round to have darkness effect applied to it or removed.

yufra
Perspiring Physicist
Posts: 1332
Joined: Tue Jul 13, 2010 2:53 pm

Re: quick question

#4 Post by yufra »

marchewka wrote:Thx for the answer. Checking the first two in the code. Regarding #3 - say i want to make a floor with shifting shadows, a tile that has 1/4 chance each round to have darkness effect applied to it or removed.
You will want to make the newEntity have an act function, which will then be called each game turn. Try looking at the infamous collapsing sand walls in ToME which can be found in `tome/data/general/grids/sand.lua`. This is the specific section:

Code: Select all

		local sand = require("engine.Object").new{
			name = "unstable sand tunnel", image = "terrain/sand.png",
			display = '.', color={r=203,g=189,b=72}, back_color={r=93,g=79,b=22},
			canAct = false,
			act = function(self)
				self:useEnergy()
				self.temporary = self.temporary - 1
				if self.temporary <= 0 then
					game.level.map(self.x, self.y, engine.Map.TERRAIN, self.old_feat)
					game.level:removeEntity(self)
					game.logSeen(self, "The unstable sand tunnel collapses!")
					game.nicer_tiles:updateAround(game.level, self.x, self.y)

					local a = game.level.map(self.x, self.y, engine.Map.ACTOR)
					if a then
						game.logPlayer(a, "You are crushed by the collapsing tunnel! You suffocate!")
						a:suffocate(30, self, "was buried alive")
						engine.DamageType:get(engine.DamageType.PHYSICAL).projector(self, self.x, self.y, engine.DamageType.PHYSICAL, a.life / 2)
					end
				end
			end,
			tunneler_dig = 1,
			dig = function(src, x, y, old)
				old.temporary = 20
				return nil, old, true
			end,
		}
Note that this is not an `engine.Grid` instance, but an `engine.Object` instance.
<DarkGod> lets say it's intended

Post Reply