mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-09-02 04:23:37 +00:00
implemented CPU player building a land factory
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
AbilityType = {SPEED = 0}
|
||||
|
||||
ablilities = {
|
||||
{type = AbilityType.SPEED, ammount = .2, units = {UnitClass.WAR_MECH}}
|
||||
}
|
||||
@@ -1,26 +1,70 @@
|
||||
function Player:foo1()
|
||||
print('foo 1')
|
||||
function Player:selectTaskForce()
|
||||
taskForce = self:getSelectedUnitsByClass(UnitClass.TANK)
|
||||
return #taskForce > 5
|
||||
end
|
||||
|
||||
function Player:issueMoveOrder()
|
||||
return false
|
||||
end
|
||||
|
||||
function Player:selectLandFactory()
|
||||
return false
|
||||
end
|
||||
|
||||
function Player:trainTaskForce()
|
||||
return false
|
||||
end
|
||||
|
||||
function Player:selectLandCell()
|
||||
return true
|
||||
end
|
||||
|
||||
function Player:foo2()
|
||||
print('foo 2')
|
||||
return true
|
||||
function Player:selectEngi()
|
||||
taskForce = self:getSelectedUnitsByClass(UnitClass.ENGINEER)
|
||||
|
||||
if #taskForce == 0 then
|
||||
self:selectUnits({self:getUnit(0)})
|
||||
end
|
||||
|
||||
taskForce = self:getSelectedUnitsByClass(UnitClass.ENGINEER)
|
||||
return #taskForce > 0
|
||||
end
|
||||
|
||||
function Player:foo3()
|
||||
print('foo 3')
|
||||
return true
|
||||
end
|
||||
function Player:issueBuildOrder()
|
||||
for i = 1, self:getNumUnits() do
|
||||
if self:getUnit(i - 1):getUnitClass() == UnitClass.LAND_FACTORY then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function Player:foo4()
|
||||
print('foo 4')
|
||||
spawnPoint = self:getSpawnPoint()
|
||||
structure = GameObjectFactory.createUnit(self, 8, spawnPoint, Quaternion:new(1, 0, 0, 0), 0)
|
||||
self:addUnit(structure)
|
||||
|
||||
targets = {Target:new(structure, Vector3:new(0, 0, 0))}
|
||||
self:issueOrder(1, Vector3:new(0, 0, 0), targets, false)
|
||||
return true
|
||||
end
|
||||
|
||||
Player.behaviour = {
|
||||
type = BTNodeType.SEQUENCE,
|
||||
type = BTNodeType.SELECTOR,
|
||||
children = {
|
||||
{type = BTNodeType.FUNCTION, func = Player.foo3}
|
||||
{
|
||||
type = BTNodeType.SEQUENCE, children = {
|
||||
{type = BTNodeType.FUNCTION, func = 'selectTaskForce'},
|
||||
{type = BTNodeType.FUNCTION, func = 'issueMoveOrder'},
|
||||
},
|
||||
type = BTNodeType.SEQUENCE, children = {
|
||||
{type = BTNodeType.FUNCTION, func = 'selectLandFactory'},
|
||||
{type = BTNodeType.FUNCTION, func = 'trainTaskForce'}
|
||||
},
|
||||
type = BTNodeType.SEQUENCE, children = {
|
||||
{type = BTNodeType.FUNCTION, func = 'selectLandCell'},
|
||||
{type = BTNodeType.FUNCTION, func = 'selectEngi'},
|
||||
{type = BTNodeType.FUNCTION, func = 'issueBuildOrder'}
|
||||
}
|
||||
}
|
||||
--[[
|
||||
]]--
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
--TYPE = {ATTACK = 0, BUILD = 1, MOVE = 2, GARRISON = 3, EJECT = 4, PATROL = 5, LAUNCH = 6};
|
||||
UnitClass = {WAR_MECH = 0, TANK = 1, ARTILLERY = 2, ENGINEER = 3, TRANSPORT = 4, CARGO_SHIP = 5, CARRIER = 6, SUBMARINE = 7, LAND_FACTORY = 8, NAVAL_FACTORY = 9, MARKET = 10, LAB = 11, POINT_DEFENSE = 12}
|
||||
UnitType = {UNDERWATER = 0, SEA_LEVEL = 1, HOVER = 2, LAND = 3, AIR = 4}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
technologies = {
|
||||
{
|
||||
name = '',
|
||||
cost = 10,
|
||||
icon = '',
|
||||
description = '',
|
||||
abilities = {0},
|
||||
units = {}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
BTNodeType = {SELECTOR = 0, SEQUENCE = 1, FUNCTION = 2}
|
||||
|
||||
function executeBtNode(btNode)
|
||||
function executeBtNode(agent, btNode)
|
||||
for i = 1, #btNode.children do
|
||||
if btNode.children[i].type == BTNodeType.FUNCTION then
|
||||
res = btNode.children[i].func()
|
||||
func = btNode.children[i].func
|
||||
res = agent[func](agent)
|
||||
else
|
||||
res = executeBtNode(btNode.children[i])
|
||||
res = executeBtNode(agent, btNode.children[i])
|
||||
end
|
||||
|
||||
if btNode.type == BTNodeType.SELECTOR then
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
Structure = {}
|
||||
|
||||
function Structure:new{Unit:new()}
|
||||
Structure.behaviour = {
|
||||
type = BTNodeType.SEQUENCE,
|
||||
children = {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
Unit = {}
|
||||
|
||||
function Unit:new(un)
|
||||
unit = un or {}
|
||||
self.__index = index
|
||||
setmetatable(unit, self)
|
||||
return unit
|
||||
end
|
||||
Unit.behaviour = {
|
||||
type = BTNodeType.SEQUENCE,
|
||||
children = {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
Vehicle = {}
|
||||
|
||||
function Vehicle:new{Unit:new()}
|
||||
Vehicle.behaviour = {
|
||||
type = BTNodeType.SEQUENCE,
|
||||
children = {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user