Commit 4b5509bb0cd2c4153f8a905060f7e8e5d9f46944

Authored by DarkGod
2 parents a5f7fb80 715ebe95

Merge branch 'rework_step_up' into 'master'

Modify Step Up

## Change
1. Each kill provides a 2-turn buff that gives 1000% movement speed in several moves, and any action other than moving will remove the buff.

## Reasons
1. Removes raw talent level usage & removes old-fashioned callback in Actor.lua
2. Makes Step Up more predictable and reliable, that no matter how much energy you have (which you cannot know in-game), you'll always benefit from Step Up and do not need to guess the remaining steps you could make.
3. Talent level above 5 gives small bonus

See merge request !744
... ... @@ -3173,10 +3173,6 @@ function _M:die(src, death_note)
3173 3173 p.kills = p.kills + 1
3174 3174 end
3175 3175
3176   - if src and src.knowTalent and src:knowTalent(src.T_STEP_UP) and rng.percent(src:getTalentLevelRaw(src.T_STEP_UP) * 20) then
3177   - game:onTickEnd(function() src:setEffect(self.EFF_STEP_UP, 1, {}) end)
3178   - end
3179   -
3180 3176 if src and self.reset_rush_on_death and self.reset_rush_on_death == src then
3181 3177 game:onTickEnd(function()
3182 3178 src:alterTalentCoolingdown(src.T_RUSH, -1000)
... ...
... ... @@ -40,16 +40,25 @@ newTalent{
40 40 end,
41 41 }
42 42
43   -newTalent{ -- Doesn't scale past level 5, could use some bonus for higher talent levels
  43 +newTalent{
44 44 name = "Step Up",
45 45 type = {"technique/battle-tactics", 2},
46 46 require = techs_req_high2,
47 47 mode = "passive",
48 48 points = 5,
  49 + getSteps = function(self, t)
  50 + local globalSpeedBonus = math.max(1, self.global_speed or 1)
  51 + return math.ceil(self:combatTalentScale(t, 1, 7) * globalSpeedBonus)
  52 + end,
  53 + callbackOnKill = function(self, t)
  54 + game:onTickEnd(function() self:setEffect(self.EFF_STEP_UP, 2, { nb = t.getSteps(self, t)}) end)
  55 + end,
49 56 info = function(self, t)
50   - return ([[After killing a foe, you have a %d%% chance to gain a 1000%% movement speed bonus for 1 game turn.
  57 + local steps = t.getSteps(self, t)
  58 + return ([[After killing a foe, you gain a 1000%% movement speed bonus in next %d steps for 2 turns.
51 59 The bonus disappears as soon as any action other than moving is done.
52   - Note: since you will be moving very fast, game turns will pass very slowly.]]):tformat(math.min(100, self:getTalentLevelRaw(t) * 20))
  60 + The maximum steps increases with your current global speed.
  61 + Note: since you will be moving very fast, game turns will pass very slowly.]]):tformat(steps)
53 62 end,
54 63 }
55 64
... ...
... ... @@ -1299,21 +1299,30 @@ newEffect{
1299 1299 newEffect{
1300 1300 name = "STEP_UP", image = "talents/step_up.png",
1301 1301 desc = _t"Step Up",
1302   - long_desc = function(self, eff) return ("Movement is %d%% faster."):tformat(eff.power) end,
  1302 + long_desc = function(self, eff) return ("Movement is 1000%% faster for next %d moves."):tformat(eff.nb or 1) end,
1303 1303 type = "physical",
1304 1304 subtype = { speed=true, tactic=true },
1305 1305 status = "beneficial",
1306 1306 parameters = {power=1000},
1307 1307 on_gain = function(self, err) return _t"#Target# prepares for the next kill!", _t"+Step Up" end,
1308 1308 on_lose = function(self, err) return _t"#Target# slows down.", _t"-Step Up" end,
  1309 + charges = function(self, eff) return eff.nb or 1 end,
1309 1310 get_fractional_percent = function(self, eff)
1310 1311 local d = game.turn - eff.start_turn
1311 1312 return util.bound(360 - d / eff.possible_end_turns * 360, 0, 360)
1312 1313 end,
1313 1314 lists = 'break_with_step_up',
  1315 + callbackOnMove = function(self, eff, moved, force, ox, oy)
  1316 + if not moved or force then return end
  1317 + if self:attr("free_movement") then return end
  1318 + eff.nb = (eff.nb or 1) - 1
  1319 + if eff.nb <= 0 then
  1320 + self:removeEffect(self.EFF_STEP_UP, false, true)
  1321 + end
  1322 + end,
1314 1323 activate = function(self, eff)
1315 1324 eff.start_turn = game.turn
1316   - eff.possible_end_turns = 10 * (eff.dur+1)
  1325 + eff.possible_end_turns = 10 * (eff.dur+2)
1317 1326 eff.tmpid = self:addTemporaryValue("step_up", 1)
1318 1327 eff.moveid = self:addTemporaryValue("movement_speed", eff.power/100)
1319 1328 -- should change priorities rather than forbid all talents
... ... @@ -1322,7 +1331,7 @@ newEffect{
1322 1331 deactivate = function(self, eff)
1323 1332 self:removeTemporaryValue("step_up", eff.tmpid)
1324 1333 if eff.aiid then self:removeTemporaryValue("ai_state", eff.aiid) end
1325   - self:removeTemporaryValue("movement_speed", eff.moveid)
  1334 + if eff.moveid then self:removeTemporaryValue("movement_speed", eff.moveid) end
1326 1335 end,
1327 1336 }
1328 1337
... ...