The Veins of the Earth

If you have a module that you'd like comments on or would like to know how to create your very own module, post here

Moderator: Moderator

Post Reply
Message
Author
lukep
Sher'Tul Godslayer
Posts: 1709
Joined: Mon Mar 14, 2011 10:32 am
Location: Canada

Re: The Veins of the Earth

#61 Post by lukep »

Ran into a couple more bugs, then decided to code-dive:

You can put 5 points into skills at lvl 1, not 4.

I got a slick chainmail of shadow, and it threw Lua errors when inspected. local shadow was a nil value. No clue what caused it.

Attacked by a Huge Centipede, data/damage_types:102 attempt to call method "fortitudeSave" (a nil value). That's the location for WATER damage, not sure what's happening there.

Lava creates infinite Lua errors (attempt to index local "dam", a number value)

I think all skill checks are broken. In Actor.lua, changing line 694 in "function _M:skillCheck(skill, dc, silent)" from:

Code: Select all

	local result = d + (getSkill(skill) or 0) 
to:

Code: Select all

	local result = d + (self:getSkill(skill) or 0) 
seems to fix it (though the intuition check shown in the log is then displaying just the roll, no bonuses)

For weapons, the reason that you can wield a two handed weapon in your offhand is that is inherits offslot = "OFF_HAND" from the base = "BASE_WEAPON". I think that adding "offslot = false" to the weapons should fix it, but I'm not sure.
(also, you didn't need to make so many bases for the weapons, a base is only useful if you use it multiple times)

Dwarf/Duregar Fighters get 22 HP per level (line 375 of class.lua should be "else" not "end" for the favored class bonuses)

Fighters don't get shield proficiency, should they?

Druid skill points is only +2 instead of +4 for the first level. (line 286 of class.lua)

Cleric Favored class HP is +1 per level instead of +10 (line 237 of Class.lua)

Wizards are the only class not to get +1 attack per level with their favored race bonuses?

EDIT:

Damage reduction is "dam" for adamantium armour/shields, but combat.lua checks for "combat_dr" for damage reduction.

The combat damage calculation is broken in _M:attackTarget. It always does 1d4 damage because it calls for self.combat instead of for the weapon's damage. self.weapon is not defined, so none of those bonuses work either.

Finesse may want to check if your dexterity is actually higher than your strength, so it doesn't apply a penalty.

The attack calculation on line 98 of Combat.lua should refer to "(weapon and weapon.combat.magic_bonus or 0)" not "(self.weapon and self.weapon.combat.magic_bonus or 0)"
Some of my tools for helping make talents:
Melee Talent Creator
Annotated Talent Code (incomplete)

lukep
Sher'Tul Godslayer
Posts: 1709
Joined: Mon Mar 14, 2011 10:32 am
Location: Canada

Re: The Veins of the Earth

#62 Post by lukep »

Welp, I got bored, and redid combat.lua, mostly to see if I could. Here's the highlights:

- re-ordered the code a bit. _M:attackTarget now only chooses the weapons, attack modifier, and percentage of strength damage to add for the attacks, and _M:attackRoll now takes that info to determine hits, crits, and damage
- You automatically miss on a roll of 1 (not 0)
- attack rolls meeting the AC now hit
- Finesse has penalties to attack if you have a shield, and is disabled if it is worse than not using it.
- Critical threats require a hit (to prevent weird effects with high-threat weapons)
- Critical hit damage is applied before damage resistance, and only applies to damage through dice, not magic or STR.
- attack damage calculated correctly
- Offhand and two weapon fighting penalties applied correctly
- Additional mainhand attacks are automatically gained at 6, 11, and 16 BAB, at -5, -10, and -15 attack, respectively
- Additional offhand attacks from improved/greater TWF feats applied at -5 and -10 attack
- attack rolls equaling the AC now hit instead of miss
- Offhand attacks get only 50% of Str mod as bonus damage
- With nothing in offhand, and while wielding a non-light, non-double weapon, wield it twohanded to deal 150% of str mod as bonus damage.

Known bugs:
- Damage resistance is never called (combat_dr is not used outside of Combat.lua)
- I broke archery (should be a fairly simple fix, I think)
- Improved Critical is not implemented
- Attacking unarmed does not have non-proficiency penalties
- It's a random mix of tabs and 4x spaces for keeping code in line.
- I only modified weapons to be double weapons on my end (add double = true to their properties)
- Rapiers can be wielded twohanded for 150% str mod bonus damage.

Code (modified from 0.9, also attached below as .txt):

Code: Select all

-- Veins of the Earth
-- Zireael
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
--


require "engine.class"
local DamageType = require "engine.DamageType"
local Map = require "engine.Map"
local Target = require "engine.Target"
local Talents = require "engine.interface.ActorTalents"

--- Interface to add ToME combat system
module(..., package.seeall, class.make)

--- Checks what to do with the target
-- Talk ? attack ? displace ?
function _M:bumpInto(target)
    local reaction = self:reactionToward(target)
    if reaction < 0 then
        return self:attackTarget(target)
    elseif reaction >= 0 then
        if self.move_others then
            -- Displace
            game.level.map:remove(self.x, self.y, Map.ACTOR)
            game.level.map:remove(target.x, target.y, Map.ACTOR)
            game.level.map(self.x, self.y, Map.ACTOR, target)
            game.level.map(target.x, target.y, Map.ACTOR, self)
            self.x, self.y, target.x, target.y = target.x, target.y, self.x, self.y
        end
    end
end

function _M:attackTarget(target, noenergy)
	if self.combat then
		-- returns your weapon if you are armed, or unarmed combat.
		local weapon = (self:getInven("MAIN_HAND") and self:getInven("MAIN_HAND")[1]) or self
		-- returns your offhand weapon (not shield) or your weapon again if it is double
		local offweapon = (self:getInven("OFF_HAND") and self:getInven("OFF_HAND")[1] and self:getInven("OFF_HAND")[1].combat and self:getInven("OFF_HAND")[1]) or (weapon and weapon.double and weapon)

		local twohanded = false

		if not (self:getInven("OFF_HAND") and self:getInven("OFF_HAND")[1]) and not weapon.double and not weapon.light then
			twohanded = true
		end


		-- add in modifiers for dualwielding, etc.
		local attackmod = 0
		local strmod = 1

		if twohanded then strmod = 1.5 end

		if offweapon then
			attackmod = -6
			if offweapon.light or weapon.double then attackmod = attackmod + 2 end
			if self:knowTalent(self.T_TWO_WEAPON_FIGHTING) then attackmod = attackmod + 2 end
		end

		self:attackRoll(target, weapon, attackmod, strmod)

		--extra attacks for high BAB, at lower bonuses
		if self.combat_bab >=6 then
			self:attackRoll(target, weapon, attackmod - 5, strmod)
		end
		if self.combat_bab >=11 then
			self:attackRoll(target, weapon, attackmod - 10, strmod)
		end
		if self.combat_bab >=16 then
			self:attackRoll(target, weapon, attackmod - 15, strmod)
		end
		
		-- offhand/double weapon attacks
		if offweapon then
			strmod = 0.5
			attackmod = -10
			if offweapon.light or weapon.double then attackmod = attackmod + 2 end
			if self:knowTalent(self.T_TWO_WEAPON_FIGHTING) then attackmod = attackmod + 6 end

			self:attackRoll(target, offweapon, attackmod, strmod)

			if self:knowTalent(self.T_IMPROVED_TWO_WEAPON_FIGHTING) then
				self:attackRoll(target, offweapon, attackmod - 5, strmod)
			end
			if self:knowTalent(self.T_GREATER_TWO_WEAPON_FIGHTING) then
				self:attackRoll(target, offweapon, attackmod - 10, strmod)
			end
		end
	end

 -- We use up our own energy
	if not noenergy then
		self:useEnergy(game.energy_to_act)
	end
end

function _M:attackRoll(target, weapon, atkmod, strmod)
	local d = rng.range(1,20)
	local hit = true
	local crit = false
    local attack = (self.combat_bab or 0) + (self.combat_attack or 0)

	-- Proficiency penalties
    if weapon and weapon.simple and not self:knowTalent(self.T_SIMPLE_WEAPON_PROFICIENCY) then 
        attack = (attack -4)
    end

	if weapon and weapon.martial and not self:knowTalent(self.T_MARTIAL_WEAPON_PROFICIENCY) then 
		attack = (attack -4) 
	end

	-- Feat bonuses
	if self:knowTalent(self.T_WEAPON_FOCUS) and weapon and weapon.subtype == self.weapon_type then 
		attack = (attack + 1) 
	end

	-- Stat bonuses
	local stat_used = "str"

	if weapon and weapon.ranged then
		stat_used = "dex"
	end

    -- Finesse
	if self:knowTalent(self.T_FINESSE) and weapon and not weapon.ranged then

		local success = false

        -- hack to get the armour check penalty of the shield.  Returns 4 instead of 10 for tower shields, and does not account for mithril bonuses.
        local shield = self:getInven("OFF_HAND") and self:getInven("OFF_HAND")[1] and self:getInven("OFF_HAND")[1].subtype == shield and self:getInven("OFF_HAND")[1].wielder.combat_shield

		if not weapon.light then
            local a = {"rapier", "whip", "spiked chain"}
            for _, w in pairs(a) do
                if weapon.subtype == w then
                    success = true
                    break
                end
            end
        else
            success = true
        end

        -- final check if Finesse improves attack
        if self:getStat("dex") > self:getStat("str") + shield * 2 then
            success = false
        end

        if success then
            stat_used = "dex"
        end
	end

	attack = attack + (atkmod or 0) + (weapon and weapon.combat.magic_bonus or 0) + (self:getStat(stat_used)-10)/2 or 0

	local ac = target:getAC()

	-- Hit check
    if self:isConcealed(target) and rng.chance(self:isConcealed(target)) then hit = false
    elseif d == 1 then hit = false
    elseif d == 20 then hit = true
    elseif d + attack < ac then hit = false
    end

	-- log message
    if hit then
        game.log(("%s hits the enemy! %d + %d = %d vs AC %d"):format(self.name:capitalize(), d, attack, d+attack, ac))
    else
        game.log(("%s misses the enemy! %d + %d = %d vs AC %d"):format(self.name:capitalize(), d, attack, d+attack, ac))
    end


    -- Crit check TODO Improved Critical
    local threat = 0 + (weapon and weapon.combat.threat or 0)
    if hit and d >= 20 - threat then 
		-- threatened critical hit confirmation roll
		if not (rng.range(1,20) + attack < ac) then 
			crit = true 
		end 
	end 
    
	if hit then
		local dam = rng.dice(self.combat.dam[1],self.combat.dam[2])

		if crit then
            game.log(("%s makes a critical attack!"):format(self.name:capitalize()))
			dam = dam * (weapon and weapon.combat.critical or 2)
		end

		-- magic damage bonus
		dam = dam + (weapon and weapon.combat.magic_bonus or 0)

		-- Stat damage bonus

		if weapon and weapon.ranged then 
			strmod = strmod or 0
		else 
			strmod = strmod or 1
		end

		dam = dam + strmod * (self:getStr()-10)/2

		if self:knowTalent(self.T_FAVORED_ENEMY) then
            if target.type ~= "humanoid" then 
                if target.type == self.favored_enemy then dam = dam + 2 end
            else 
                if target.subtype == self.favored_enemy then dam = dam + 2 end
            end
        end    

		--Minimum 1 point of damage unless Damage Reduction works
        dam = math.max(1, dam)
        dam = dam - (target.combat_dr or 0)

        target:takeHit(dam, self)
        game.log(("%s deals %d damage to %s!"):format(self.name:capitalize(), dam, target.name:capitalize()))
	end
end


Attachments
Combat.txt
(7.49 KiB) Downloaded 162 times
Some of my tools for helping make talents:
Melee Talent Creator
Annotated Talent Code (incomplete)

Zireael
Archmage
Posts: 449
Joined: Tue Jun 18, 2013 7:24 pm

Re: The Veins of the Earth

#63 Post by Zireael »

First off, lukep, big thanks for that combat patch!
lukep wrote:Ran into a couple more bugs, then decided to code-dive:

You can put 5 points into skills at lvl 1, not 4.
I fail Maths forever.
I got a slick chainmail of shadow, and it threw Lua errors when inspected. local shadow was a nil value. No clue what caused it.
Probably some item tooltip code malfunctioning. I will check it.
Attacked by a Huge Centipede, data/damage_types:102 attempt to call method "fortitudeSave" (a nil value). That's the location for WATER damage, not sure what's happening there.
Been trying to pin this one down for a few days. My best guess is something's drowning offscreen.
Lava creates infinite Lua errors (attempt to index local "dam", a number value)
Will look into it.
I think all skill checks are broken. In Actor.lua, changing line 694 in "function _M:skillCheck(skill, dc, silent)" from:

Code: Select all

	local result = d + (getSkill(skill) or 0) 
to:

Code: Select all

	local result = d + (self:getSkill(skill) or 0) 
seems to fix it (though the intuition check shown in the log is then displaying just the roll, no bonuses)
Fix incoming.
For weapons, the reason that you can wield a two handed weapon in your offhand is that is inherits offslot = "OFF_HAND" from the base = "BASE_WEAPON". I think that adding "offslot = false" to the weapons should fix it, but I'm not sure.
(also, you didn't need to make so many bases for the weapons, a base is only useful if you use it multiple times)
Fix incoming.
Dwarf/Duregar Fighters get 22 HP per level (line 375 of class.lua should be "else" not "end" for the favored class bonuses)

Druid skill points is only +2 instead of +4 for the first level. (line 286 of class.lua)

Cleric Favored class HP is +1 per level instead of +10 (line 237 of Class.lua)
Whoa, that's a lot of silly typos, thanks for pointing them out!
Damage reduction is "dam" for adamantium armour/shields, but combat.lua checks for "combat_dr" for damage reduction.
Fix incoming.
Wizards are the only class not to get +1 attack per level with their favored race bonuses?
Yes, this is intended and is now noted when you create a character.
Fighters don't get shield proficiency, should they?
They should, but shield proficiency does nothing for the moment.

lukep
Sher'Tul Godslayer
Posts: 1709
Joined: Mon Mar 14, 2011 10:32 am
Location: Canada

Re: The Veins of the Earth

#64 Post by lukep »

Zireael wrote:First off, lukep, big thanks for that combat patch!
You're welcome! Glad to help.

I let a bug slip through, though. Line 204 of Combat.lua should read:

Code: Select all

local dam = rng.dice(weapon.combat.dam[1],weapon.combat.dam[2])
It was using unarmed combat damage instead of the weapon's.

Also found one in your commits, the "end" on line 383 of class.lua should be moved up one line, so that dwarf fighters get skill points.
Some of my tools for helping make talents:
Melee Talent Creator
Annotated Talent Code (incomplete)

Zireael
Archmage
Posts: 449
Joined: Tue Jun 18, 2013 7:24 pm

Re: The Veins of the Earth

#65 Post by Zireael »

Grab beta 4 from here!

If you need the module itself, remember it now requires T-Engine 1.0.5g.

CHANGELOG:

* bug fix: eldritch blast lua error fixed
* bug fix: shield no longer counts as offhand weapon for TWF
* bug fix: druid skill points are now set to 2
* bug fix: dwarf fighters & drow clerics receive the proper amount of hp
* bug fix: apply skill bonuses properly in the checks
* bug fix: no more wielding two-handed weapons with one hand
* bug fix: all spells (including sorcerer and spell-like abilities) now display their proper icon
* bug fix: drowning and lava lua errors fixed
* new class: sorcerer
* chat code added
* highscores working & enabled (based on the number of total kills)
* made combat & skill logs clearer
* you can now talk to some NPCs
* new terrain and rooms: ice floor, shafts, swamp
* helpful information added to character creation
* character screen now displays ALL the classes you have
* expanded random feats list
* clerics can now turn undead
* point buy added for attributes generation
* archery feats coded in
* random perks part 2: you can now get a random spell as a perk, too
* wizards can now choose school specialization [Seb]
* right-clicking on map now brings up a context menu
* light & heavy load now works per SRD; implemented Loadbearer feat
* activable Power Attack and Combat Expertise feats

Zireael
Archmage
Posts: 449
Joined: Tue Jun 18, 2013 7:24 pm

Re: The Veins of the Earth

#66 Post by Zireael »

The next release should be quite soon (we've got Monday and Tuesday free because of national holidays in Poland).

The main feature?

TILES.

Kalarion
Low Yeek
Posts: 6
Joined: Sun Jan 20, 2013 2:48 am

Re: The Veins of the Earth

#67 Post by Kalarion »

I ran into an interesting bug.

I was unable to identify an item with Intuition, so I dropped it on the ground and picked it up again. It rerolled Intuition... but my skill modifier was lower then before. I did this several times, each time making the skill modifier go lower... and lower... and lower...

I stopped trying when my Intuition hit -41. Then I brought up my skill window and saw that ALL SKILLS were in the negatives.

No idea what caused it. My best guess is some kind of issue with trying to force new intuition rolls?

Zireael
Archmage
Posts: 449
Joined: Tue Jun 18, 2013 7:24 pm

Re: The Veins of the Earth

#68 Post by Zireael »

^^ This sounds like an issue with encumbrance and encumbrance penalties. Hopefully it's fixed now!

***

A new release, named "A thing of beauty", is out!
Grab it from here. ModDB download to come later.

Among the major changes, we migrated to T-Engine 1.0.5, so there might be some engine bugs (I hope not!)

CHANGELOG:

* bug fix: shadow armor lua error fixed [Seb]
* bug fix: apply increased Str bonus to two-handed weapons
* bug fix: chasm displays its proper name in tooltip
* bug fix: hotbar no longer covers the log on some screens
* bug fix: random naming for potions and scrolls now works properly
* bug fix: you can no longer spend one more skill point per level than intended
* TILES - using David Gervais 32x32 tiles with some new tiles made by me
* new spells: identify; improved identify, mage armor [Seb]
* new items: cursed items (bracers of clumsiness, potion of poison, potion of inflict light wounds and others); ring of darkvision
* split feat dialog into 3 columns
* add proficiency requirement to shields
* adjusted magic item drops
* Balance DC 15 or Jump DC 30 to cross a chasm
* character sheet split into two tabs; skill breakdown as a table
* containers
* show message log screen finally works
* hunger counter & food rations now work
* multiclassing now requires 13 in core ability except for sorcerers and wizards, who require 16 in CHA or INT, respectively
* cross-class skills are now coded and working

Zireael
Archmage
Posts: 449
Joined: Tue Jun 18, 2013 7:24 pm

Re: The Veins of the Earth

#69 Post by Zireael »

I've isolated the cause of the Lua error which makes it impossible for some players to open inventory. Basically, they picked up a buggy item with a name of nil. Now to track down the item (thanks self for tiles) and fix it..

truburas
Posts: 3
Joined: Fri Jul 26, 2013 8:05 pm

Re: The Veins of the Earth

#70 Post by truburas »

Great work... and waiting for tiles!

Zireael
Archmage
Posts: 449
Joined: Tue Jun 18, 2013 7:24 pm

Re: The Veins of the Earth

#71 Post by Zireael »

truburas wrote:Great work... and waiting for tiles!
What do you mean? The tiles are already in the Nov 12 build... and I've finished working on a major batch of monsters, so some more tiles remain to be done and a new version should be out soon!

Graziel
Wyrmic
Posts: 234
Joined: Wed Sep 15, 2010 10:32 am

Re: The Veins of the Earth

#72 Post by Graziel »

"A thing of beauty"

- wizard got screwed by first monster he encountered cause he didnt had any memorized spells
- 'buy points' give a bit too much points
- cant eat 'stale rations'
- cant mouse click - move in bottom and left regions
- moving on ice it ultra annoying - you have to wait for 2x success in a row to move

Code: Select all

Lua Error: /data/general/objects/potions.lua:25: attempt to concatenate a nil value
	At [C]:-1 __concat
	At /data/general/objects/potions.lua:25 
	At /engine/Entity.lua:534 resolve
	At /engine/Object.lua:42 resolve
	At /engine/Zone.lua:586 finishEntity
	At /engine/Zone.lua:393 makeEntity
	At /engine/generator/object/Random.lua:44 generateOne
	At /engine/generator/object/Random.lua:60 regenFrom
	At /engine/generator/object/Random.lua:38 generate
	At /engine/Zone.lua:895 newLevel
	At /engine/Zone.lua:801 getLevel
	At /mod/class/Game.lua:240 changeLevel
	At /mod/class/Game.lua:489 
	At /engine/KeyBind.lua:241 
You are likely to be eaten by a grue

Zireael
Archmage
Posts: 449
Joined: Tue Jun 18, 2013 7:24 pm

Re: The Veins of the Earth

#73 Post by Zireael »

- wizard got screwed by first monster he encountered cause he didnt had any memorized spells
This is game design and mechanics, not a bug.
- 'buy points' give a bit too much points
- cant mouse click - move in bottom and left regions
- moving on ice it ultra annoying - you have to wait for 2x success in a row to move
Known. Noting the other two down on git. There's nothing I can do for the points and the 2 success thing now, however. I will try to fix the map clicking (the map has to be moved up so that it isn't covered by the hotbar/log/HUD).
- cant eat 'stale rations'
To be fixed tomorrow.

***
There is a beta module available from te4.org -http://te4.org/sites/default/files/game ... .11.1.team. Report any missing tiles here. I want to get the best tileset I can before 1st Dec.

Crim, The Red Thunder
Sher'Tul Godslayer
Posts: 2000
Joined: Fri May 07, 2004 8:26 pm
Location: Nahgharash

Re: The Veins of the Earth

#74 Post by Crim, The Red Thunder »

Lowering the skill needed to walk on ice would compensate for the double check, some.

A temporary, ugly solution, but it would help some.
Currently playing under the name Aura of the Dawn 4 down, 227 to go!
Proud author of Orc Pit Restoration Project, Faction Allies, Dwarven Adventurer addons
SadistSquirrel wrote:DarkGod has two arms, one with an opened hand, one with a closed fist. You got the fist.

Zireael
Archmage
Posts: 449
Joined: Tue Jun 18, 2013 7:24 pm

Re: The Veins of the Earth

#75 Post by Zireael »

Crim, The Red Thunder wrote:Lowering the skill needed to walk on ice would compensate for the double check, some.

A temporary, ugly solution, but it would help some.
Yeah, will probably be done as 1 Dec approaches.

For now, I managed to fix encumbrance penalties, but now they spam messages and I forgot how to make the effect silent. However, I managed to cut back on the other clutter, as starting items no longer spam log messages.

Post Reply