Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function _M:getTalentFullDescription(t, addlevel, config, fake_mastery)
- if not t then return tstring{"no talent"} end
- config = config or {}
- local old = self.talents[t.id]
- if config.force_level then
- self.talents[t.id] = config.force_level
- else
- self.talents[t.id] = (self.talents[t.id] or 0) + (addlevel or 0)
- end
- local oldmastery = nil
- if fake_mastery then
- self.talents_types_mastery[t.type[1]] = fake_mastery - 1
- end
- local d = tstring{}
- d:add({"color",0x6f,0xff,0x83}, "Effective talent level: ", {"color",0x00,0xFF,0x00}, ("%.1f"):format(self:getTalentLevel(t)), true)
- if not config.ignore_mode then
- if t.mode == "passive" then d:add({"color",0x6f,0xff,0x83}, "Use mode: ", {"color",0x00,0xFF,0x00}, "Passive", true)
- elseif t.mode == "sustained" then d:add({"color",0x6f,0xff,0x83}, "Use mode: ", {"color",0x00,0xFF,0x00}, "Sustained", true)
- else d:add({"color",0x6f,0xff,0x83}, "Use mode: ", {"color",0x00,0xFF,0x00}, "Activated", true)
- end
- end
- if config.custom then
- d:merge(config.custom)
- d:add(true)
- end
- if not config.ignore_ressources then
- if t.mana then d:add({"color",0x6f,0xff,0x83}, "Mana cost: ", {"color",0x7f,0xff,0xd4}, ""..(util.getval(t.mana, self, t) * (100 + 2 * self:combatFatigue()) / 100), true) end
- if t.stamina then d:add({"color",0x6f,0xff,0x83}, "Stamina cost: ", {"color",0xff,0xcc,0x80}, ""..(util.getval(t.stamina, self, t) * (100 + self:combatFatigue()) / 100), true) end
- if t.equilibrium then d:add({"color",0x6f,0xff,0x83}, "Equilibrium cost: ", {"color",0x00,0xff,0x74}, ""..(util.getval(t.equilibrium, self, t)), true) end
- if t.vim then d:add({"color",0x6f,0xff,0x83}, "Vim cost: ", {"color",0x88,0x88,0x88}, ""..(util.getval(t.vim, self, t)), true) end
- if t.positive then d:add({"color",0x6f,0xff,0x83}, "Positive energy cost: ", {"color",255, 215, 0}, ""..(util.getval(t.positive, self, t) * (100 + self:combatFatigue()) / 100), true) end
- if t.negative then d:add({"color",0x6f,0xff,0x83}, "Negative energy cost: ", {"color", 127, 127, 127}, ""..(util.getval(t.negative, self, t) * (100 + self:combatFatigue()) / 100), true) end
- if t.hate then d:add({"color",0x6f,0xff,0x83}, "Hate cost: ", {"color", 127, 127, 127}, ""..(util.getval(t.hate, self, t) * (100 + 2 * self:combatFatigue()) / 100), true) end
- if t.paradox then d:add({"color",0x6f,0xff,0x83}, "Paradox cost: ", {"color", 176, 196, 222}, ("%0.2f"):format(util.getval(t.paradox, self, t) * (1 + (self.paradox / 300))), true) end
- if t.psi then d:add({"color",0x6f,0xff,0x83}, "Psi cost: ", {"color",0x7f,0xff,0xd4}, ""..(util.getval(t.psi, self, t) * (100 + 2 * self:combatFatigue()) / 100), true) end
- if t.feedback then d:add({"color",0x6f,0xff,0x83}, "Feedback cost: ", {"color",0xFF, 0xFF, 0x00}, ""..(util.getval(t.psi, self, t) * (100 + 2 * self:combatFatigue()) / 100), true) end
- if t.fortress_energy then d:add({"color",0x6f,0xff,0x83}, "Fortress Energy cost: ", {"color",0x00,0xff,0xa0}, ""..(t.fortress_energy), true) end
- if t.sustain_mana then d:add({"color",0x6f,0xff,0x83}, "Sustain mana cost: ", {"color",0x7f,0xff,0xd4}, ""..(util.getval(t.sustain_mana, self, t)), true) end
- if t.sustain_stamina then d:add({"color",0x6f,0xff,0x83}, "Sustain stamina cost: ", {"color",0xff,0xcc,0x80}, ""..(util.getval(t.sustain_stamina, self, t)), true) end
- if t.sustain_equilibrium then d:add({"color",0x6f,0xff,0x83}, "Sustain equilibrium cost: ", {"color",0x00,0xff,0x74}, ""..(util.getval(t.sustain_equilibrium, self, t)), true) end
- if t.sustain_vim then d:add({"color",0x6f,0xff,0x83}, "Sustain vim cost: ", {"color",0x88,0x88,0x88}, ""..(util.getval(t.sustain_vim, self, t)), true) end
- if t.sustain_positive then d:add({"color",0x6f,0xff,0x83}, "Sustain positive energy cost: ", {"color",255, 215, 0}, ""..(util.getval(t.sustain_positive, self, t)), true) end
- if t.sustain_negative then d:add({"color",0x6f,0xff,0x83}, "Sustain negative energy cost: ", {"color", 127, 127, 127}, ""..(util.getval(t.sustain_negative, self, t)), true) end
- if t.sustain_hate then d:add({"color",0x6f,0xff,0x83}, "Sustain hate cost: ", {"color", 127, 127, 127}, ""..(util.getval(t.sustain_hate, self, t)), true) end
- if t.sustain_paradox then d:add({"color",0x6f,0xff,0x83}, "Sustain paradox cost: ", {"color", 176, 196, 222}, ("%0.2f"):format(util.getval(t.sustain_paradox, self, t)), true) end
- if t.sustain_psi then d:add({"color",0x6f,0xff,0x83}, "Sustain psi cost: ", {"color",0x7f,0xff,0xd4}, ""..(util.getval(t.sustain_psi, self, t)), true) end
- if t.sustain_feedback then d:add({"color",0x6f,0xff,0x83}, "Sustain feedback cost: ", {"color",0xFF, 0xFF, 0x00}, ""..(util.getval(t.sustain_feedback, self, t)), true) end
- self:triggerHook{"Actor:getTalentFullDescription:ressources", str=d, t=t, addlevel=addlevel, config=config, fake_mastery=fake_mastery}
- end
- if t.mode ~= "passive" then
- if self:getTalentRange(t) > 1 then d:add({"color",0x6f,0xff,0x83}, "Range: ", {"color",0xFF,0xFF,0xFF}, ("%0.2f"):format(self:getTalentRange(t)), true)
- else d:add({"color",0x6f,0xff,0x83}, "Range: ", {"color",0xFF,0xFF,0xFF}, "melee/personal", true)
- end
- if not config.ignore_ressources then
- if self:getTalentCooldown(t) then d:add({"color",0x6f,0xff,0x83}, "Cooldown: ", {"color",0xFF,0xFF,0xFF}, ""..self:getTalentCooldown(t), true) end
- end
- local speed = self:getTalentProjectileSpeed(t)
- if speed then d:add({"color",0x6f,0xff,0x83}, "Travel Speed: ", {"color",0xFF,0xFF,0xFF}, ""..(speed * 100).."% of base", true)
- else d:add({"color",0x6f,0xff,0x83}, "Travel Speed: ", {"color",0xFF,0xFF,0xFF}, "instantaneous", true)
- end
- if not config.ignore_use_time then
- local uspeed = "1 turn"
- if t.no_energy and type(t.no_energy) == "boolean" and t.no_energy == true then uspeed = "instant" end
- d:add({"color",0x6f,0xff,0x83}, "Usage Speed: ", {"color",0xFF,0xFF,0xFF}, uspeed, true)
- end
- local is_a = {}
- if t.is_spell then is_a[#is_a+1] = "a spell" end
- if t.is_mind then is_a[#is_a+1] = "a mind power" end
- if t.is_nature then is_a[#is_a+1] = "a nature gift" end
- if t.is_summon then is_a[#is_a+1] = " a summon power" end
- if #is_a > 0 then
- d:add({"color",0x6f,0xff,0x83}, "Is: ", {"color",0xFF,0xFF,0xFF}, table.concatNice(is_a, ", ", " and "), true)
- end
- else
- if not config.ignore_ressources then
- if self:getTalentCooldown(t) then d:add({"color",0x6f,0xff,0x83}, "Cooldown: ", {"color",0xFF,0xFF,0xFF}, ""..self:getTalentCooldown(t), true) end
- end
- end
- self:triggerHook{"Actor:getTalentFullDescription", str=d, t=t, addlevel=addlevel, config=config, fake_mastery=fake_mastery}
- d:add({"color",0x6f,0xff,0x83}, "Description: ", {"color",0xFF,0xFF,0xFF})
- d:merge(t.info(self, t):toTString():tokenize(" ()[]"))
- self.talents[t.id] = old
- if fake_mastery then
- self.talents_types_mastery[t.type[1]] = oldmastery
- end
- return d
- end
- function _M:preUseTalent(ab, silent, fake)
- if self:attr("feared") and (ab.mode ~= "sustained" or not self:isTalentActive(ab.id)) then
- if not silent then game.logSeen(self, "%s is too afraid to use %s.", self.name:capitalize(), ab.name) end
- return false
- end
- -- When silenced you can deactivate spells but not activate them
- if ab.no_silence and self:attr("silence") and (ab.mode ~= "sustained" or not self:isTalentActive(ab.id)) then
- if not silent then game.logSeen(self, "%s is silenced and cannot use %s.", self.name:capitalize(), ab.name) end
- return false
- end
- if ab.is_spell and self:attr("forbid_arcane") and (ab.mode ~= "sustained" or not self:isTalentActive(ab.id)) then
- if not silent then game.logSeen(self, "The spell fizzles.") end
- return false
- end
- -- Nature is forbidden to undead (just wild-gifts for now)
- if ab.is_nature and self:attr("forbid_nature") and (ab.mode ~= "sustained" or not self:isTalentActive(ab.id)) then
- if not silent then game.logSeen(self, "%s is too disconnected from Nature to use %s.", self.name:capitalize(), ab.name) end
- return false
- end
- if ab.is_inscription and self.inscription_restrictions and not self.inscription_restrictions[ab.type[1]] then
- if not silent then game.logSeen(self, "%s is unable to use this kind of inscription.", self.name:capitalize()) end
- return false
- end
- -- when using unarmed techniques check for weapons and heavy armor
- if ab.is_unarmed and not (ab.mode == "sustained" and self:isTalentActive(ab.id)) then
- -- first check for heavy and massive armor
- if self:hasMassiveArmor() then
- if not silent then game.logSeen(self, "You are too heavily armoured to use this talent.") end
- return false
- -- next make sure we're unarmed
- elseif not self:isUnarmed() then
- if not silent then game.logSeen(self, "You can't use this talent while holding a weapon or shield.") end
- return false
- end
- end
- if not self:enoughEnergy() and not fake then return false end
- if ab.mode == "sustained" then
- if ab.sustain_mana and self.max_mana < util.getval(ab.sustain_mana, self, ab) and not self:isTalentActive(ab.id) then
- if not silent then game.logPlayer(self, "You do not have enough mana to activate %s.", ab.name) end
- return false
- end
- if ab.sustain_stamina and self.max_stamina < util.getval(ab.sustain_stamina, self, ab) and not self:isTalentActive(ab.id) then
- if not silent then game.logPlayer(self, "You do not have enough stamina to activate %s.", ab.name) end
- return false
- end
- if ab.sustain_vim and self.max_vim < util.getval(ab.sustain_vim, self, ab) and not self:isTalentActive(ab.id) then
- if not silent then game.logPlayer(self, "You do not have enough vim to activate %s.", ab.name) end
- return false
- end
- if ab.sustain_positive and self.max_positive < util.getval(ab.sustain_positive, self, ab) and not self:isTalentActive(ab.id) then
- if not silent then game.logPlayer(self, "You do not have enough positive energy to activate %s.", ab.name) end
- return false
- end
- if ab.sustain_negative and self.max_negative < util.getval(ab.sustain_negative, self, ab) and not self:isTalentActive(ab.id) then
- if not silent then game.logPlayer(self, "You do not have enough negative energy to activate %s.", ab.name) end
- return false
- end
- if ab.sustain_hate and self.max_hate < util.getval(ab.sustain_hate, self, ab) and not self:isTalentActive(ab.id) then
- if not silent then game.logPlayer(self, "You do not have enough hate to activate %s.", ab.name) end
- return false
- end
- if ab.sustain_psi and self.max_psi < util.getval(ab.sustain_psi, self, ab) and not self:isTalentActive(ab.id) then
- if not silent then game.logPlayer(self, "You do not have enough energy to activate %s.", ab.name) end
- return false
- end
- elseif not self:attr("force_talent_ignore_ressources") then
- if ab.mana and self:getMana() < util.getval(ab.mana, self, ab) * (100 + 2 * self:combatFatigue()) / 100 then
- if not silent then game.logPlayer(self, "You do not have enough mana to cast %s.", ab.name) end
- return false
- end
- if ab.stamina and self:getStamina() < util.getval(ab.stamina, self, ab) * (100 + self:combatFatigue()) / 100 and (not self:hasEffect(self.EFF_ADRENALINE_SURGE) or self.life < ab.stamina * (100 + self:combatFatigue()) / 100) then
- if not silent then game.logPlayer(self, "You do not have enough stamina to use %s.", ab.name) end
- return false
- end
- if ab.vim and self:getVim() < util.getval(ab.vim, self, ab) and (not self:attr("bloodcasting") or self.life < ab.vim) then
- if not silent then game.logPlayer(self, "You do not have enough vim to use %s.", ab.name) end
- return false
- end
- if ab.positive and self:getPositive() < util.getval(ab.positive, self, ab) * (100 + self:combatFatigue()) / 100 then
- if not silent then game.logPlayer(self, "You do not have enough positive energy to use %s.", ab.name) end
- return false
- end
- if ab.negative and self:getNegative() < util.getval(ab.negative, self, ab) * (100 + self:combatFatigue()) / 100 then
- if not silent then game.logPlayer(self, "You do not have enough negative energy to use %s.", ab.name) end
- return false
- end
- if ab.hate and self:getHate() < util.getval(ab.hate, self, ab) * (100 + self:combatFatigue()) / 100 then
- if not silent then game.logPlayer(self, "You do not have enough hate to use %s.", ab.name) end
- return false
- end
- if ab.psi and self:getPsi() < util.getval(ab.psi, self, ab) * (100 + 2 * self:combatFatigue()) / 100 then
- if not silent then game.logPlayer(self, "You do not have enough energy to use %s.", ab.name) end
- return false
- end
- if ab.feedback and self:getFeedback() < util.getval(ab.feedback, self, ab) * (100 + 2 * self:combatFatigue()) / 100 then
- if not silent then game.logPlayer(self, "You do not have enough feedback to use %s.", ab.name) end
- return false
- end
- if ab.fortress_energy and game:getPlayer(true):hasQuest("shertul-fortress") and game:getPlayer(true):hasQuest("shertul-fortress").shertul_energy < ab.fortress_energy then
- if not silent then game.logPlayer(self, "You do not have enough fortress energy to use %s.", ab.name) end
- return false
- end
- end
- -- Equilibrium is special, it has no max, but the higher it is the higher the chance of failure (and loss of the turn)
- -- But it is not affected by fatigue
- if (ab.equilibrium or (ab.sustain_equilibrium and not self:isTalentActive(ab.id))) and not fake and not self:attr("force_talent_ignore_ressources") then
- -- Fail ? lose energy and 1/10 more equilibrium
- if (not self:attr("no_equilibrium_fail") and (not self:attr("no_equilibrium_summon_fail") or not ab.is_summon)) and not self:equilibriumChance(ab.equilibrium or ab.sustain_equilibrium) then
- if not silent then game.logPlayer(self, "You fail to use %s due to your equilibrium!", ab.name) end
- self:incEquilibrium((ab.equilibrium or ab.sustain_equilibrium) / 10)
- self:useEnergy()
- return false
- end
- end
- -- Spells can fail
- if (ab.is_spell and not self:isTalentActive(ab.id)) and not fake and self:attr("spell_failure") then
- if rng.percent(self:attr("spell_failure")) then
- if not silent then game.logSeen(self, "%s's %s has been disrupted by #ORCHID#anti-magic forces#LAST#!", self.name:capitalize(), ab.name) end
- self:useEnergy()
- return false
- end
- end
- -- Paradox is special, it has no max, but the higher it is the higher the chance of something bad happening
- if (ab.paradox and ab.paradox > 0 or (ab.sustain_paradox and ab.sustain_paradox > 0 and not self:isTalentActive(ab.id))) and not fake and not self:attr("force_talent_ignore_ressources") then
- -- Check anomalies first since they can reduce paradox, this way paradox is a self correcting resource
- local paradox_scaling = 1 + self.paradox / 300
- if not game.zone.no_anomalies and not self:attr("no_paradox_fail") and self:paradoxAnomalyChance() then
- -- Random anomaly
- local ts = {}
- for id, t in pairs(self.talents_def) do
- if t.type[1] == "chronomancy/anomalies" then ts[#ts+1] = id end
- end
- if not silent then game.logPlayer(self, "#LIGHT_RED#You lose control and unleash an anomaly!") end
- self:forceUseTalent(rng.table(ts), {ignore_energy=true})
- -- Anomalies correct the timeline and reduce Paradox
- self:incParadox(- (ab.paradox and (ab.paradox * paradox_scaling) or ab.sustain_paradox) * 2)
- game:playSoundNear(self, "talents/distortion")
- self:useEnergy()
- return false
- -- Now check for failure
- elseif not self:attr("no_paradox_fail") and self:paradoxFailChance() and not self:hasEffect(self.EFF_SPACETIME_STABILITY) then
- if not silent then game.logPlayer(self, "#LIGHT_RED#You fail to use %s due to your paradox!", ab.name) end
- self:incParadox(ab.paradox and (ab.paradox * paradox_scaling) or ab.sustain_paradox)
- self:useEnergy()
- game:playSoundNear(self, "talents/dispel")
- return false
- end
- end
- if self:triggerHook{"Actor:preUseTalent", t=ab, silent=silent, fale=fake} then
- return false
- end
- -- Confused ? lose a turn!
- if self:attr("confused") and (ab.mode ~= "sustained" or not self:isTalentActive(ab.id)) and ab.no_energy ~= true and not fake and not self:attr("force_talent_ignore_ressources") then
- if rng.percent(self:attr("confused")) then
- if not silent then game.logSeen(self, "%s is confused and fails to use %s.", self.name:capitalize(), ab.name) end
- self:useEnergy()
- return false
- end
- end
- -- Failure chance?
- if self:attr("talent_fail_chance") and (ab.mode ~= "sustained" or not self:isTalentActive(ab.id)) and ab.no_energy ~= true and not fake and not self:attr("force_talent_ignore_ressources") then
- if rng.percent(self:attr("talent_fail_chance")) then
- if not silent then game.logSeen(self, "%s fails to use %s.", self.name:capitalize(), ab.name) end
- self:useEnergy()
- return false
- end
- end
- -- terrified effect
- if self:attr("terrified") and (ab.mode ~= "sustained" or not self:isTalentActive(ab.id)) and ab.no_energy ~= true and not fake and not self:attr("force_talent_ignore_ressources") then
- local eff = self:hasEffect(self.EFF_TERRIFIED)
- if rng.percent(self:attr("terrified")) then
- if not silent then game.logSeen(self, "%s is too terrified to use %s.", self.name:capitalize(), ab.name) end
- self:useEnergy()
- return false
- end
- end
- -- Special checks
- if ab.on_pre_use and not (ab.mode == "sustained" and self:isTalentActive(ab.id)) and not ab.on_pre_use(self, ab, silent, fake) then return false end
- if self:attr("use_only_arcane") then
- if self:attr("use_only_arcane") >= 2 then if ab.type[1] ~= "spell/arcane" and ab.type[1] ~= "spell/aether" and ab.type[1] ~= "spell/aegis" then return false end
- elseif self:attr("use_only_arcane") >= 1 then if ab.type[1] ~= "spell/arcane" and ab.type[1] ~= "spell/aether" then return false end
- end
- end
- -- Cant heal
- if ab.is_heal and (self:attr("no_healing") or ((self.healing_factor or 1) <= 0)) then return false end
- if ab.is_teleport and self:attr("encased_in_ice") then return false end
- if not silent then
- -- Allow for silent talents
- if ab.message ~= nil then
- if ab.message then
- game.logSeen(self, "%s", self:useTalentMessage(ab))
- end
- elseif ab.mode == "sustained" and not self:isTalentActive(ab.id) then
- game.logSeen(self, "%s activates %s.", self.name:capitalize(), ab.name)
- elseif ab.mode == "sustained" and self:isTalentActive(ab.id) then
- game.logSeen(self, "%s deactivates %s.", self.name:capitalize(), ab.name)
- elseif ab.is_spell then
- game.logSeen(self, "%s casts %s.", self.name:capitalize(), ab.name)
- elseif not ab.no_message then
- game.logSeen(self, "%s uses %s.", self.name:capitalize(), ab.name)
- end
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment