Skip to content
Snippets Groups Projects
Commit d2023d67 authored by dg's avatar dg
Browse files

fixed npc acting

git-svn-id: http://svn.net-core.org/repos/t-engine4@187 51575b47-30f0-44d4-a5cc-537603b46e54
parent 72f206f4
No related branches found
No related tags found
No related merge requests found
Showing
with 65 additions and 26 deletions
......@@ -130,6 +130,7 @@ end
function _M:useEnergy(val)
val = val or game.energy_to_act
self.energy.value = self.energy.value - val
self.energy.used = true
if self.player and self.energy.value < game.energy_to_act then game.paused = false end
end
......
......@@ -35,11 +35,12 @@ function _M:tick()
local arr = self.level.e_array
for i = 1, #arr do
e = arr[i]
if e and e.act then
if e.energy and e.energy.value < self.energy_to_act then
if e and e.act and e.energy then
if e.energy.value < self.energy_to_act then
e.energy.value = (e.energy.value or 0) + self.energy_per_tick * (e.energy.mod or 1)
end
if e.energy.value >= self.energy_to_act then
e.energy.used = false
e:act(self)
end
end
......@@ -49,11 +50,12 @@ function _M:tick()
local arr = self.entities
for i, e in pairs(arr) do
e = arr[i]
if e and e.act then
if e.energy and e.energy.value < self.energy_to_act then
if e and e.act and e.energy then
if e.energy.value < self.energy_to_act then
e.energy.value = (e.energy.value or 0) + self.energy_per_tick * (e.energy.mod or 1)
end
if e.energy.value >= self.energy_to_act then
e.energy.used = false
e:act(self)
end
end
......
......@@ -23,7 +23,10 @@ end)
newAI("dumb_talented_simple", function(self)
if self:runAI("target_simple") then
-- One in "talent_in" chance of using a talent
if rng.chance(self.ai_state.talent_in or 6) and not self:runAI("dumb_talented") then
if rng.chance(self.ai_state.talent_in or 6) then
self:runAI("dumb_talented")
end
if not self.energy.used then
self:runAI("move_simple")
end
return true
......
......@@ -32,6 +32,6 @@ function resolvers.talents(list)
end
function resolvers.calc.talents(t, e)
local ts = {}
for i, tid in ipairs(t[1]) do ts[tid] = true end
for tid, level in pairs(t[1]) do ts[tid] = level end
return ts
end
......@@ -145,8 +145,8 @@ end
function _M:levelup()
self.unused_stats = self.unused_stats + 3
self.unused_talents = self.unused_talents + 1
if self.level % 5 == 0 then
self.unused_talents = self.unused_talents + 2
if self.level % 10 == 0 then
self.unused_talents_types = self.unused_talents_types + 1
end
......
......@@ -15,9 +15,8 @@ function _M:act()
-- Let the AI think .... beware of Shub !
-- If AI did nothing, use energy anyway
local old = self.energy.value
self:doAI()
if old == self.energy.value then self:useEnergy() end
if not self.energy.used then self:useEnergy() end
end
--- Called by ActorLife interface
......
......@@ -127,7 +127,7 @@ function _M:attackTargetWith(target, weapon, damtype, mult)
local crit
dam = dam * mult
dam, crit = self:physicalCrit(dam, weapon)
game.logSeen(self, "%s performs a critical stike!", self.name:capitalize())
if crit then game.logSeen(self, "%s performs a critical stike!", self.name:capitalize()) end
DamageType:get(damtype).projector(self, target.x, target.y, damtype, math.max(0, dam))
hitted = true
else
......
......@@ -8,11 +8,11 @@ newEntity{
combat = { dam=1, atk=1, apr=1 },
body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 },
equipment = resolvers.equip{ {type="weapon", subtype="longsword"} },
equipment = resolvers.equip{ {type="weapon", subtype="greatsword"} },
drops = resolvers.drops{chance=20, nb=1, {} },
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=3, },
ai = "dumb_talented_simple", ai_state = { talent_in=4, },
energy = { mod=1 },
stats = { str=14, dex=12, mag=10, con=12 },
......@@ -24,7 +24,7 @@ newEntity{ base = "BASE_NPC_SKELETON",
name = "degenerated skeleton warrior", color=colors.WHITE,
level_range = {1, 50}, exp_worth = 1,
rarity = 4,
max_life = resolvers.rngavg(30,40),
max_life = resolvers.rngavg(40,50),
combat_armor = 5, combat_def = 1,
}
......@@ -32,16 +32,17 @@ newEntity{ base = "BASE_NPC_SKELETON",
name = "skeleton warrior", color=colors.SLATE,
level_range = {2, 50}, exp_worth = 1,
rarity = 3,
max_life = resolvers.rngavg(40,50),
max_life = resolvers.rngavg(90,100),
combat_armor = 5, combat_def = 1,
talents = resolvers.talents{ [Talents.T_STAMINA_POOL]=1, [Talents.T_STUNNING_BLOW]=1, [Talents.T_DEATH_BLOW]=1 },
}
newEntity{ base = "BASE_NPC_SKELETON",
name = "skeleton mage", color=colors.LIGHT_RED,
level_range = {4, 50}, exp_worth = 1,
rarity = 6,
max_life = resolvers.rngavg(20,25),
max_mana = resolvers.rngavg(40,50),
max_life = resolvers.rngavg(50,60),
max_mana = resolvers.rngavg(70,80),
combat_armor = 3, combat_def = 1,
stats = { str=10, dex=12, cun=14, mag=14, con=10 },
talents = resolvers.talents{ [Talents.T_MANA_POOL]=1, [Talents.T_FLAME]=2, [Talents.T_MANATHRUST]=3 },
......
......@@ -24,16 +24,17 @@ newTalent{
return {
stealth = self:addTemporaryValue("stealth", self:getCun(10) * self:getTalentLevel(t)),
lite = self:addTemporaryValue("lite", -100),
-- lite = self:addTemporaryValue("lite", -100),
}
end,
deactivate = function(self, t, p)
self:removeTemporaryValue("stealth", p.stealth)
self:removeTemporaryValue("lite", p.lite)
-- self:removeTemporaryValue("lite", p.lite)
return true
end,
info = function(self, t)
return ([[Enters stealth mode, making you harder to detect.
Stealth cannot work with heavy or massive armours.
While in stealth mode, light radius is reduced to 0.
There needs to be no foes in sight in a radius of %d around you to enter stealth.]]):format(math.floor(10 - self:getTalentLevel(t) * 1.3))
end,
......@@ -47,6 +48,6 @@ newTalent{
require = { stat = { cun=18 }, },
info = function(self, t)
return ([[When striking from stealth, hits are automatically criticals if the target does not notice you.
Shadowstrikes do %.02f%% more damage than a normal hit.]]):format(math.floor(2 + self:getTalentLevel(t) / 5))
Shadowstrikes do %.02f%% damage than a normal hit.]]):format((2 + self:getTalentLevel(t) / 5) * 100)
end,
}
......@@ -99,3 +99,35 @@ newTalent{
return ([[Greatly increases attack speed, but drains stamina quickly.]])
end,
}
newTalent{
name = "Momentum",
type = {"physical/dualweapon", 3},
mode = "sustained",
points = 5,
cooldown = 30,
sustain_stamina = 50,
require = { stat = { dex=20 }, },
activate = function(self, t)
local weapon = self:getInven("MAINHAND")[1]
local offweapon = self:getInven("OFFHAND")[1]
if not weapon or not offweapon or not weapon.combat or not offweapon.combat then
game.logPlayer(self, "You cannot use Flurry without dual wielding!")
return nil
end
return {
combat_physspeed = self:addTemporaryValue("combat_physspeed", -0.1 - self:getTalentLevel(t) / 10),
stamina_regen = self:addTemporaryValue("stamina_regen", -5),
}
end,
deactivate = function(self, t, p)
self:removeTemporaryValue("combat_physspeed", p.combat_physspeed)
self:removeTemporaryValue("stamina_regen", p.stamina_regen)
return true
end,
info = function(self)
return ([[Greatly increases attack speed, but drains stamina quickly.]])
end,
}
......@@ -12,10 +12,10 @@ newTalent{
local target = self
if self:getTalentLevel(t) >= 5 then
local tx, ty = self:getTarget{default_target=self, type="hit", range=10}
if tx and ty then
target = game.level.map(tx, ty, Map.ACTOR) or self
end
-- local tx, ty = self:getTarget{type="hit", range=10}
-- if tx and ty then
-- target = game.level.map(tx, ty, Map.ACTOR) or self
-- end
end
local x, y = self.x, self.y
......@@ -25,7 +25,7 @@ newTalent{
-- Target code doesnot restrict the target coordinates to the range, it lets the poject function do it
-- but we cant ...
x, y = game.target:pointAtRange(self.x, self.y, x, y, 10 + self:combatSpellpower(0.1))
target:teleportRandom(x, y, 20 - self:getTalentLevel(t))
target:teleportRandom(x, y, 7 - self:getTalentLevel(t))
else
target:teleportRandom(x, y, 10 + self:combatSpellpower(0.1))
end
......
......@@ -4,7 +4,7 @@ return {
level_scheme = "player",
max_level = 5,
width = 50, height = 50,
-- all_remembered = true,
all_remembered = true,
-- all_lited = true,
-- persistant = true,
generator = {
......
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment