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

nature's call

summoner AI


git-svn-id: http://svn.net-core.org/repos/t-engine4@269 51575b47-30f0-44d4-a5cc-537603b46e54
parent 94b6e52d
No related branches found
No related tags found
No related merge requests found
......@@ -23,11 +23,11 @@ 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) then
if rng.chance(self.ai_state.talent_in or 6) and self:reactionToward(self.ai_target.actor) < 0 then
self:runAI("dumb_talented")
end
if not self.energy.used then
self:runAI("move_simple")
self:runAI(self.ai_move or "move_simple")
end
return true
end
......
......@@ -274,6 +274,40 @@ function core.fov.beam_grids(x, y, radius, dir, angle, block)
return grids
end
--- Finds free grids around coords in a radius.
-- This will return a random grid, the closest possible to the epicenter
-- @param sx the epicenter coordinates
-- @param sy the epicenter coordinates
-- @param radius the radius in which to search
-- @param block true if we only consider line of sight
-- @param what a table which can have the fields Map.ACTOR, Map.OBJECT, ..., set to true. If so it will only return grids that are free of this kind of entities.
function util.findFreeGrid(sx, sy, radius, block, what)
what = what or {}
local grids = core.fov.circle_grids(sx, sy, radius, block)
local gs = {}
for x, yy in pairs(grids) do for y, _ in pairs(yy) do
local ok = true
for w, _ in pairs(what) do
if game.level.map(x, y, w) then ok = false end
end
if ok then
gs[#gs+1] = {x, y, math.floor(core.fov.distance(sx, sy, x, y)), rng.range(1, 1000)}
end
end end
if #gs == 0 then return nil end
table.sort(gs, function(a, b)
if a[3] == b[3] then
return a[4] < b[4]
else
return a[3] < b[3]
end
end)
return gs[1][1], gs[1][2]
end
function util.showMainMenu()
local Menu = require("special.mainmenu.class.Game")
game = Menu.new()
......
......@@ -37,3 +37,63 @@ newTalent{
The life healed will increase with the Magic stat]]):format(10 + self:combatSpellpower(0.5) * self:getTalentLevel(t))
end,
}
newTalent{
name = "Nature's Call",
type = {"spell/nature", 3},
require = spells_req3,
points = 5,
mana = 60,
cooldown = 100,
tactical = {
ATTACK = 10,
},
action = function(self, t)
-- Find space
local x, y = util.findFreeGrid(self.x, self.y, 5, true, {[Map.ACTOR]=true})
if not x then
game.logPlayer(self, "Not enough space to invoke the guardian!")
return
end
print("Invoking gardian on", x, y)
local NPC = require "mod.class.NPC"
local bear = NPC.new{
type = "animal", subtype = "bear",
display = "q", color=colors.LIGHT_GREEN,
name = "guardian bear", faction = "players",
desc = [[A bear summoned by the powers of nature to help you.]],
autolevel = "warrior",
ai = "summoned", ai_real = "dumb_talented_simple", ai_state = { talent_in=5, },
energy = { mod=1 },
stats = { str=18, dex=13, mag=5, con=15 },
tmasteries = resolvers.tmasteries{ ["physical/other"]=0.25 },
talents = resolvers.talents{ [Talents.T_STUN]=2 },
max_stamina = 100,
resists = { [DamageType.COLD] = 20, [DamageType.NATURE] = 20 },
level_range = {self.level, self.level}, exp_worth = 0,
max_life = resolvers.rngavg(100,150),
life_rating = 10,
combat_armor = 7, combat_def = 3,
combat = { dam=resolvers.rngavg(12,25), atk=10, apr=10, physspeed=2 },
summoner = self,
summon_time = util.bound(self:getTalentLevel(t) * self:combatSpellpower(25), 5, 90),
}
bear:resolve()
bear:move(x, y, true)
game.level:addEntity(bear)
bear:added()
return true
end,
info = function(self, t)
return ([[Call upon the forces of nature to summon bear ally for %d turns.
The power of the ally will increase with the Magic stat]]):format(util.bound(self:getTalentLevel(t) * self:combatSpellpower(25), 5, 90))
end,
}
......@@ -18,6 +18,20 @@ dofile("/mod/colors.lua")
-- Additional entities resolvers
dofile("/mod/resolvers.lua")
-- Body parts
ActorInventory:defineInventory("MAINHAND", "In main hand", true, "Most weapons are wielded in the main hand.")
ActorInventory:defineInventory("OFFHAND", "In off hand", true, "You can use shields or a second weapon in your off hand, if you have the talents for it.")
ActorInventory:defineInventory("FINGER", "On fingers", true, "Rings are worn on fingers.")
ActorInventory:defineInventory("NECK", "Around neck", true, "Amulets are worn around the neck.")
ActorInventory:defineInventory("LITE", "Light source", true, "Light source allows you to see in the dark places of the world.")
ActorInventory:defineInventory("BODY", "Main armor", true, "Armor protects your from physical attacks. The heavier the armor the more it hinders the use of talents and spells.")
ActorInventory:defineInventory("CLOAK", "Cloak", true, "A cloak can simply keep you warn or grant you wonderous powers should you find a magic one.")
ActorInventory:defineInventory("HEAD", "On head", true, "You can wear helmets or crowns on your head")
ActorInventory:defineInventory("BELT", "Around waist", true, "Belts are worn around waist.")
ActorInventory:defineInventory("HANDS", "On hands", true, "Various gloves can be worn on your hands.")
ActorInventory:defineInventory("FEET", "On feet", true, "Sandals or boots can be worn on your feet.")
ActorInventory:defineInventory("TOOL", "Tool", true, "This is your readied tool, always available immediately.")
-- Damage types
DamageType:loadDefinition("/data/damage_types.lua")
-- Talents
......@@ -40,20 +54,7 @@ ActorStats:defineStat("Luck", "lck", 50, 1, 100, "Luck defines your character's
dofile("/data/autolevel_schemes.lua")
-- Actor AIs
ActorAI:loadDefinition("/engine/ai/")
-- Body parts
ActorInventory:defineInventory("MAINHAND", "In main hand", true, "Most weapons are wielded in the main hand.")
ActorInventory:defineInventory("OFFHAND", "In off hand", true, "You can use shields or a second weapon in your off hand, if you have the talents for it.")
ActorInventory:defineInventory("FINGER", "On fingers", true, "Rings are worn on fingers.")
ActorInventory:defineInventory("NECK", "Around neck", true, "Amulets are worn around the neck.")
ActorInventory:defineInventory("LITE", "Light source", true, "Light source allows you to see in the dark places of the world.")
ActorInventory:defineInventory("BODY", "Main armor", true, "Armor protects your from physical attacks. The heavier the armor the more it hinders the use of talents and spells.")
ActorInventory:defineInventory("CLOAK", "Cloak", true, "A cloak can simply keep you warn or grant you wonderous powers should you find a magic one.")
ActorInventory:defineInventory("HEAD", "On head", true, "You can wear helmets or crowns on your head")
ActorInventory:defineInventory("BELT", "Around waist", true, "Belts are worn around waist.")
ActorInventory:defineInventory("HANDS", "On hands", true, "Various gloves can be worn on your hands.")
ActorInventory:defineInventory("FEET", "On feet", true, "Sandals or boots can be worn on your feet.")
ActorInventory:defineInventory("TOOL", "Tool", true, "This is your readied tool, always available immediately.")
ActorAI:loadDefinition("/mod/ai/")
-- Birther descriptor
Birther:loadDefinition("/data/birth/descriptors.lua")
......
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