I added a bunch of comments to the arcane power talent, and plan on doing a few others as well. This is to give anyone interested in learning to develop new talents, modify existing ones, or simply understand them better a solid starting point, and outline what all of the common functions and terms do.
Most of this is quite obvious by the names, but some have nuances and features that would not be apparent at first look.
I'm planning on doing a few other talents as well, at least one spell attack, one martial attack, and one passive, with others added in as needed. They would not have nearly this much information added to them, as I would not duplicate information across multiple talents.
Here's what I have so far: (corrections, additions, comments, and clarifications would be appreciated)
Code: Select all
newTalent{
-- Start here
name = "Arcane Power",
-- the name that is displayed to the player. It also determines the short name and image, unless they are overridden by their own entries.
-- short_name = "ARCANE_POWER"
-- what the code refers to this talent by. This must be unique, or else problems arise. Within the code for this talent, it is also referred to as "t". This is usually automatically based on the name.
-- image = "talents/arcane_power.png"
-- the icon for the talent that is displayed in the levelup screen as well as on the talent bar. This is usually automatically based on the name.
type = {"spell/arcane", 1},
-- The tree and tier of the talent.
mode = "sustained",
-- The three modes are activated, sustained, and passive. Talents are passive by default.
require = spells_req1,
-- The requirements to get this talent, usually a stat and character level. It is found in data/talents/spells/spells.lua
sustain_mana = 50,
-- sustain_mana and any other sustain resources reduce your maximum capacity of the resource instead of costing some amount of your current.
points = 5,
-- How many class or generic points can be invested into the talent. This is (almost) always 5.
cooldown = 30,
-- How long you need to wait before using the talent again. For sustains this starts when the sustain is deactivated, not when it is started.
tactical = { BUFF = 2 },
-- Information for the tactical AI used by elite and better enemies.
spellpower_increase = { 5, 9, 13, 16, 18 },
-- a variable. It can be retrieved within the talent by t.spellpower_increase, or anywhere else by defining local t = self:getTalentFromId(self.T_ARCANE_POWER), then using it.
getSpellpowerIncrease = function(self, t)
-- a function. It can be retrieved within the talent by t.getSpellpowerincrease(self, t), or anywhere else by defining local t = self:getTalentFromId(self.T_ARCANE_POWER), then using it.
local v = t.spellpower_increase[self:getTalentLevelRaw(t)]
-- a local variable. It can be retrieved until the next line that is tabbed out less than where it was defined by using its name (without putting "local" in front).
-- Call a entry in a table (things inside {}) by using an integer in square brackets like []. 1 returns the first entry, 2 returns the second etc…
if v then return v else return 18 + (self:getTalentLevelRaw(t) - 5) * 2 end
-- boolean operators are if, then, else, and, or, not
-- The return statement is the value, true/false, or anything else. To return nothing, use return nil.
end,
-- this marks the end of the function
activate = function(self, t)
-- This function is called when you activate the sustain
game:playSoundNear(self, "talents/arcane")
-- This plays a sound if the player is near the source. This sound file is data/sound/talents/arcane.ogg
-- game:playSound (self, "talents/arcane")
-- This plays a sound, regardless of the source. Do not use this in most cases.
return {
-- This is what using the sustained talent does. Note that this is called when it is started being sustained, and is not updated with changing stats after that.
power = self:addTemporaryValue("combat_spellpower", t.getSpellpowerIncrease(self, t)),
-- Adds a temporary bonus/malus to the character, in this case as much spellpower as is determined by the function.
particle = self:addParticles(Particles.new("arcane_power", 1)),
-- Adds a particle effect to the character. This particle file is data/gfx/particles/arcane_power.lua
}
end,
deactivate = function(self, t, p)
-- This is called when the sustain is deactivated. It should remove everything that activating it adds, or else problems result.
self:removeParticles(p.particle)
self:removeTemporaryValue("combat_spellpower", p.power)
return true
end,
info = function(self, t)
-- the description that the player sees when mousing over the talent.
local spellpowerinc = t.getSpellpowerIncrease(self, t)
-- creating local variables that call talent functions for the description is good because it is easier to read and it is resistant to breaking with balancing updates.
return ([[Your mastery of magic allows you to enter a deep concentration state, increasing your spellpower by %d.]]):
-- The description that the player sees. Anything starting in a % sign is replaced by the term in "format" below.
-- %d = whole number, %0.2f = two decimal places, %0.3f = three decimal places, %% = "%" is displayed,
format(spellpowerinc)
-- Terms that replace the % things in the description, separated by commas.
end,
}
-- end here