Expanding preUseTalent

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
yufra
Perspiring Physicist
Posts: 1332
Joined: Tue Jul 13, 2010 2:53 pm

Expanding preUseTalent

#1 Post by yufra »

I believe there has been some confusion about when talents are actually used by players since the talent message (eg. "Player rushes out") is displayed even though the talent may fail or be canceled due to targeting. I have played a bit with this in my module, and propose the following for discussion.

We can add a check in preUseTalent just after checking the resources and before printing the message:

Code: Select all

	-- Check for special preuse
	if ab.on_preuse and not ab.on_preuse(self, ab) then
		return false
	end
The on_preuse function can take handle simple things like ammo for bows/slings (so that the bad ammo messages still appear but the "Player shoots" does not). The on_preuse function could also handle the talent targetting, although then there is the issue of where to store the targeting information (probably in the actor). For example, here is my on_preuse function for the Stealth talent:

Code: Select all

	on_preuse = function(self, t)
		-- Check nearby actors
		local grids = core.fov.circle_grids(self.x, self.y, math.floor(10 - self:getTalentLevel(t) * 1.1), true)
		for x, yy in pairs(grids) do for y in pairs(yy) do
			local actor = game.level.map(x, y, game.level.map.ACTOR)
			if actor and actor ~= self and actor:reactionToward(self) < 0 and not rng.percent(self.hide_chance or 0) then
				game.logPlayer(self, "You cannot Stealth with nearby foes watching!")
				return nil
			end
		end end
		return true
	end,
A corresponding on_postuse function could also be implemented. Thoughts?
<DarkGod> lets say it's intended

Feanor.81
Wyrmic
Posts: 239
Joined: Mon Aug 23, 2010 12:52 pm
Location: Poggibonsi (Siena), Italy

Re: Expanding preUseTalent

#2 Post by Feanor.81 »

It would definitely be a great addition, I hate that fake messages in the log when actually I was not able to use a talent!

Thumbs up!
Don't fear the eyes of the Dark Lord / Morgoth I cry
All hope is gone, but I swear revenge / Hear my oath
I will take part in your damned fate

Post Reply