hotfix: revert some shit caused by merge
make the boar work with new AI features
This commit is contained in:
parent
d33d6eedd6
commit
c2c33cbf1b
@ -156,37 +156,6 @@ local behavior = {}
|
||||
behavior.__index = behavior
|
||||
behavior.id = "ai"
|
||||
|
||||
function behavior:dev_warrior()
|
||||
return function(callback) -- почему так, описано в Task
|
||||
self.owner:try(Tree.behaviors.spellcaster, function(spellB)
|
||||
self.target = pathToClosestCharacter(self.owner, 1)
|
||||
local attackTarget = closestCharacter(self.owner):has(Tree.behaviors.positioned)
|
||||
if not attackTarget then return end
|
||||
local task1 = spellB.spellbook[1]:cast(self.owner, self.target)
|
||||
if task1 then
|
||||
task1(
|
||||
function()
|
||||
-- здесь мы оказываемся после того, как сходили в первый раз
|
||||
print('[AI]: я походил')
|
||||
local task2 = spellB.spellbook[3]:cast(self.owner, attackTarget.position)
|
||||
if task2 then
|
||||
-- дергаем функцию после завершения хода
|
||||
print('[AI]: и ударил')
|
||||
task2(callback)
|
||||
else
|
||||
print('[AI]: чёт не бьётся')
|
||||
callback()
|
||||
end
|
||||
end
|
||||
)
|
||||
else
|
||||
print('рот этого казино')
|
||||
callback()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
--- @param class Class
|
||||
function behavior.new(class)
|
||||
return setmetatable({
|
||||
|
||||
15
main.lua
15
main.lua
@ -45,27 +45,16 @@ function love.load()
|
||||
Tree.behaviors.shadowcaster.new(),
|
||||
Tree.behaviors.spellcaster.new()
|
||||
},
|
||||
character.spawn("Baris")
|
||||
character.spawn("BOAR")
|
||||
:addBehavior {
|
||||
Tree.behaviors.residentsleeper.new(),
|
||||
Tree.behaviors.stats.new(nil, nil, 2),
|
||||
Tree.behaviors.positioned.new(Vec3 { 5, 5 }),
|
||||
Tree.behaviors.tiled.new(),
|
||||
Tree.behaviors.sprite.new(Tree.assets.files.sprites.character),
|
||||
Tree.behaviors.shadowcaster.new(),
|
||||
Tree.behaviors.spellcaster.new(),
|
||||
Tree.behaviors.ai.new("dev_warrior") -- так мы вообще делать не должны, и он должен как-то подцеплять class из stats, но как я хз честно
|
||||
},
|
||||
character.spawn("BOAR")
|
||||
:addBehavior {
|
||||
Tree.behaviors.residentsleeper.new(),
|
||||
Tree.behaviors.stats.new(nil, nil, 2),
|
||||
Tree.behaviors.positioned.new(Vec3 { 7, 7 }),
|
||||
Tree.behaviors.tiled.new(),
|
||||
Tree.behaviors.sprite.new(Tree.assets.files.sprites.boar),
|
||||
Tree.behaviors.shadowcaster.new(),
|
||||
Tree.behaviors.spellcaster.new(),
|
||||
Tree.behaviors.ai.new()
|
||||
Tree.behaviors.ai.new("dev_warrior")
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user