Хранитель
| В запасе |
Faction: Предтечи
Join Date: Feb 2013
Location: Нижневартовск
Posts: 51
|
Re: Скрипты ai (папка data::ai)
race.lua
Code:
-- LuaDC version 0.9.20
-- 17.11.2013 12:40:31
-- LuaDC by Age2uN
-- on error send source file (compiled lua) and this outputfile to Age2uN@gmx.net
--
NotPlayable = 0
Playable = 1
races =
{
{ "Invalid", "Invalid", "", "", 0, NotPlayable, "", },
{ "Hiigaran", "$1100", "hyperspace_gate", "etg/special/SPECIAL_ABILITIES_HYPERSPACE_IN", 9.5, Playable, "HGN_", },
{ "Tobari", "Tobari", "hyperspace_gate_vgr", "etg/special/SPECIAL_ABILITIES_HYPERSPACE_IN", 9.5, Playable, "TBR_", },
{ "Vaygr", "$1101", "hyperspace_gate_vgr", "etg/special/SPECIAL_ABILITIES_HYPERSPACE_IN", 9.5, Playable, "VGR_", },
{ "Keeper", "$1102", "hyperspace_gate_kpr", "etg/special/SPECIAL_ABILITIES_HYPERSPACE_IN", 12.5, NotPlayable, "KPR_", },
{ "Bentusi", "$1103", "hyperspace_gate_bentusi", "etg/special/SPECIAL_ABILITIES_HYPERSPACE_IN", 18.5, NotPlayable, "BEN_", },
{ "GreatProgenitors", "Great Progenitors", "hyperspace_gate_kpr", "etg/special/SPECIAL_ABILITIES_HYPERSPACE_IN", 9.5, NotPlayable, "PRG_", },
{ "Random", "$3226", "", "", 0, Playable, "", },
}
familylist.lua
Code:
-- LuaDC version 0.9.20
-- 17.11.2013 13:24:01
-- LuaDC by Age2uN
-- on error send source file (compiled lua) and this outputfile to Age2uN@gmx.net
--
buildFamily =
{
{
name = "Fighter_Hgn", },
{
name = "Corvette_Hgn", },
{
name = "Mover_Hgn", },
{
name = "Frigate_Hgn", },
{
name = "SuperCap_Hgn", },
{
name = "Shipyard_Hgn", },
{
name = "Battlecruiser_Hgn", },
{
name = "Flagship_Hgn", },
{
name = "Utility_Hgn", },
{
name = "Probe_Hgn", },
{
name = "Platform_Hgn", },
{
name = "SubSystem_Hgn", },
{
name = "SubSystemLarge_Hgn", },
{
name = "Fighter_Vgr", },
{
name = "Corvette_Vgr", },
{
name = "Frigate_Vgr", },
{
name = "SuperCap_Vgr", },
{
name = "Shipyard_Vgr", },
{
name = "Battlecruiser_Vgr", },
{
name = "Flagship_Vgr", },
{
name = "Utility_Vgr", },
{
name = "Probe_Vgr", },
{
name = "Platform_Vgr", },
{
name = "SubSystem_Vgr", },
{
name = "SubSystemLarge_Vgr", },
{
name = "NotBuildable", },
{
name = "Fighter_Tbr", },
{
name = "Corvette_Tbr", },
{
name = "Frigate_Tbr", },
{
name = "SuperCap_Tbr", },
{
name = "Shipyard_Tbr", },
{
name = "Battlecruiser_Tbr", },
{
name = "Flagship_Tbr", },
{
name = "Utility_Tbr", },
{
name = "Probe_Tbr", },
{
name = "SubSystem_Tbr", },
{
name = "SubSystemLarge_Tbr", },
{
name = "Platform_Tbr", },
{
name = "Fighter_Prg", },
{
name = "Corvette_Prg", },
{
name = "Mover_Prg", },
{
name = "Frigate_Prg", },
{
name = "SuperCap_Prg", },
{
name = "Shipyard_Prg", },
{
name = "Battlecruiser_Prg", },
{
name = "Flagship_Prg", },
{
name = "Utility_Prg", },
{
name = "Probe_Prg", },
{
name = "Platform_Prg", },
{
name = "SubSystem_Prg", },
{
name = "SubSystemLarge_Prg", },
}
displayFamily =
{
{
name = "Fighter",
stringParam = "$2100",
numParam = 1, },
{
name = "Corvette",
stringParam = "$2101",
numParam = 2, },
{
name = "Frigate",
stringParam = "$2102",
numParam = 3, },
{
name = "Capital",
stringParam = "$2103",
numParam = 4, },
{
name = "Flagship",
stringParam = "$2104",
numParam = 6, },
{
name = "Platform",
stringParam = "$2105",
numParam = 7, },
{
name = "Utility",
stringParam = "$2106",
numParam = 8, },
{
name = "SubSystemModule",
stringParam = "$2107",
numParam = 9, },
{
name = "SubSystemSensors",
stringParam = "$2108",
numParam = 10, },
{
name = "Munition",
stringParam = "$2109",
numParam = 11, },
{
name = "Megalith",
stringParam = "$2110",
numParam = 12, },
}
attackFamily =
{
{
name = "Fighter",
numParam = 1, },
{
name = "Corvette",
numParam = 1, },
{
name = "Frigate",
numParam = 1, },
{
name = "Utility",
numParam = 1, },
{
name = "Munition",
numParam = 1, },
{
name = "SmallCapitalShip",
numParam = 1, },
{
name = "BigCapitalShip",
numParam = 1, },
{
name = "Mothership",
numParam = 1, },
{
name = "Emplacement",
numParam = 1, },
{
name = "UnAttackable",
numParam = 0, },
{
name = "SubSystem",
numParam = 1, },
{
name = "Resource",
numParam = 1, },
{
name = "ResourceLarge",
numParam = 1, },
{
name = "Capturer",
numParam = 1, },
{
name = "Chimera",
numParam = 1, },
}
dockFamily =
{
{
name = "Mover", },
{
name = "Fighter", },
{
name = "Corvette", },
{
name = "Frigate", },
{
name = "Utility", },
{
name = "Controller", },
{
name = "Platform", },
{
name = "SuperCap", },
{
name = "BattleCruiser", },
{
name = "Transport", },
{
name = "Shipyard", },
{
name = "Flagship", },
{
name = "Resource", },
{
name = "Inhibitor", },
{
name = "LargeSalvage", },
{
name = "UltraCap", },
{
name = "CantDock", },
}
avoidanceFamily =
{
{
name = "None",
numParam = 0, },
{
name = "DontAvoid",
numParam = 1, },
{
name = "Strikecraft",
numParam = 2, },
{
name = "Utility",
numParam = 3, },
{
name = "Frigate",
numParam = 4, },
{
name = "SmallRock",
numParam = 5, },
{
name = "Capital",
numParam = 6, },
{
name = "SuperCap",
numParam = 7, },
{
name = "BattleCruiser",
numParam = 8, },
{
name = "MotherShip",
numParam = 9, },
{
name = "BigRock",
numParam = 10, },
{
name = "SuperPriority",
numParam = 11, },
}
collisionFamily =
{
{
name = "Small",
numParam = 0, },
{
name = "Big",
numParam = 1, },
{
name = "Unmoveable",
numParam = 2, },
}
autoFormationFamily =
{
{
name = "Fighter",
numParam = 0, },
{
name = "Corvette",
numParam = 1, },
{
name = "Frigate",
numParam = 2, },
{
name = "CapShip",
numParam = 3, },
{
name = "SuperCap",
numParam = 4, },
}
armourFamily =
{
{
name = "Unarmoured", },
{
name = "LightArmour", },
{
name = "MediumArmour", },
{
name = "HeavyArmour", },
{
name = "SubSystemArmour", },
{
name = "TurretArmour", },
{
name = "ResArmour", },
{
name = "MoverArmour", },
{
name = "PlanetKillerArmour", },
{
name = "MineArmour", },
{
name = "ChunkArmour", },
}
unitcapsFamily =
{
{
name = "Fighter",
numParam = 1,
stringParam = "$2113", },
{
name = "Corvette",
numParam = 10,
stringParam = "$2114", },
{
name = "Frigate",
numParam = 20,
stringParam = "$2115", },
{
name = "Capital",
numParam = 30,
stringParam = "$2116", },
{
name = "Platform",
numParam = 40,
stringParam = "$2117", },
{
name = "Utility",
numParam = 50,
stringParam = "$2118", },
{
name = "Mothership",
numParam = 60,
stringParam = "$2119", },
{
name = "DreadNaught",
numParam = 70,
stringParam = "$2120", },
{
name = "SPMovers",
numParam = 80,
stringParam = "$2121", },
{
name = "SinglePlayerMisc",
numParam = 90,
stringParam = "This should not be displayed", },
{
name = "CommStation",
numParam = 100,
stringParam = "This should not be displayed", },
}
unitcapsShipType =
{
{
name = "MinelayerCorvette",
numParam = 11,
stringParam = "$2135", },
{
name = "Mover",
numParam = 12,
stringParam = "$2121", },
{
name = "TorpedoFrigate",
numParam = 21,
stringParam = "$2122", },
{
name = "CaptureFrigate",
numParam = 22,
stringParam = "$2123", },
{
name = "DefenseFieldFrigate",
numParam = 23,
stringParam = "$2124", },
{
name = "Destroyer",
numParam = 31,
stringParam = "$2125", },
{
name = "Carrier",
numParam = 32,
stringParam = "$2126", },
{
name = "Battlecruiser",
numParam = 33,
stringParam = "$2127", },
{
name = "Shipyard",
numParam = 34,
stringParam = "$2128", },
{
name = "HyperspacePlatform",
numParam = 41,
stringParam = "$2129", },
{
name = "ResourceCollector",
numParam = 51,
stringParam = "$2130", },
{
name = "ResourceController",
numParam = 52,
stringParam = "$2131", },
{
name = "Probe",
numParam = 53,
stringParam = "$2132", },
{
name = "ECMProbe",
numParam = 54,
stringParam = "$2133", },
{
name = "ProximitySensor",
numParam = 55,
stringParam = "$2134", },
}
startingfleets/tobari00.lua
Code:
-- LuaDC version 0.9.20
-- 17.11.2013 14:33:19
-- LuaDC by Age2uN
-- on error send source file (compiled lua) and this outputfile to Age2uN@gmx.net
--
PersistantData =
{
StrikeGroups = {},
Squadrons =
{
{
type = "Tbr_ResourceCollector",
subsystems = {},
shiphold = {},
name = "",
size = 1,
number = 6, },
{
type = "Tbr_Carrier",
subsystems = {},
shiphold = {},
name = "",
size = 1,
number = 1, },
},
Research = {}, }
Building and research Tobari:
build.lua
Code:
-- LuaDC version 0.9.20
-- 08.02.2013 14:28:19
-- LuaDC by Age2uN
-- on error send source file (compiled lua) and this outputfile to Age2uN@gmx.net
--
Ship = 0
SubSystem = 1
build =
{
{
Type = Ship,
ThingToBuild = "Tbr_Bomber",
RequiredResearch = "",
RequiredShipSubSystems = "",
DisplayPriority = 40,
DisplayedName = "Bomber",
Description = "Bomber", },
{
Type = Ship,
ThingToBuild = "Tbr_Probe",
RequiredResearch = "",
RequiredShipSubSystems = "",
DisplayPriority = 45,
DisplayedName = "Probe",
Description = "Probe", },
{
Type = Ship,
ThingToBuild = "tbr_lightmissilefrigate",
RequiredResearch = "FrigateTech",
RequiredShipSubSystems = "",
DisplayPriority = 50,
DisplayedName = "lightmissilefrigate",
Description = "lightmissilefrigate", },
{
Type = Ship,
ThingToBuild = "Tbr_AssaultCorvette",
RequiredResearch = "AssaultCorvetteTech",
RequiredShipSubSystems = "",
DisplayPriority = 55,
DisplayedName = "AssaultCorvette",
Description = "AssaultCorvette", },
{
Type = Ship,
ThingToBuild = "Tbr_BomberCorvette",
RequiredResearch = "BomberCorvetteTech",
RequiredShipSubSystems = "",
DisplayPriority = 60,
DisplayedName = "Corvette Bomber",
Description = "Corvette Bomber", },
{
Type = Ship,
ThingToBuild = "Tbr_IonTurret",
RequiredResearch = "",
RequiredShipSubSystems = "",
DisplayPriority = 65,
DisplayedName = "Ion Platform",
Description = "Ion Platform", },
{
Type = Ship,
ThingToBuild = "Tbr_Interceptor",
RequiredResearch = "",
RequiredShipSubSystems = "",
DisplayPriority = 70,
DisplayedName = "Interceptor",
Description = "Interceptor", },
{
Type = Ship,
ThingToBuild = "Tbr_Carrier",
RequiredResearch = "",
RequiredShipSubSystems = "",
DisplayPriority = 110,
DisplayedName = "Carrier",
Description = "Carrier", },
{
Type = Ship,
ThingToBuild = "Tbr_ResourceCollector",
RequiredResearch = "",
RequiredShipSubSystems = "",
DisplayPriority = 120,
DisplayedName = "Collector",
Description = "Collector", },
{
Type = Ship,
ThingToBuild = "Tbr_Destroyer",
RequiredResearch = "DestroyerTech",
RequiredShipSubSystems = "",
DisplayPriority = 125,
DisplayedName = "Destroyer",
Description = "Destroyer", },
{
Type = Ship,
ThingToBuild = "Tbr_Shipyard",
RequiredResearch = "ShipyardTech",
RequiredShipSubSystems = "",
DisplayPriority = 130,
DisplayedName = "Shipyard",
Description = "Shipyard", },
{
Type = Ship,
ThingToBuild = "Tbr_ResourceController",
RequiredResearch = "",
RequiredShipSubSystems = "",
DisplayPriority = 135,
DisplayedName = "Harvester",
Description = "Harvester", },
{
Type = Ship,
ThingToBuild = "Tbr_Battlecruiser",
RequiredResearch = "BattleCruiserTech",
RequiredShipSubSystems = "",
DisplayPriority = 140,
DisplayedName = "Cruiser",
Description = "Cruiser", },
{
Type = Ship,
ThingToBuild = "Tbr_Scout",
RequiredResearch = "",
RequiredShipSubSystems = "",
DisplayPriority = 145,
DisplayedName = "Scout",
Description = "Scout", },
}
дальше у мну комп тормозит =/ сек
research.lua
Code:
-- LuaDC version 0.9.20
-- 22.03.2014 17:10:14
-- LuaDC by Age2uN
-- on error send source file (compiled lua) and this outputfile to Age2uN@gmx.net
--
Icon_Speed = "data:ui/newui/research/icons/speed.mres"
Icon_Health = "data:ui/newui/research/icons/health.mres"
Icon_Tech = "data:ui/newui/research/icons/tech.mres"
Icon_Ability = "data:ui/newui/research/icons/ability.mres"
Icon_Build = "data:ui/newui/research/icons/build.mres"
Modifier = 0
Ability = 1
AllShips = 0
Family = 1
Ship = 2
research =
{
{
Name = "CorvetteTech",
RequiredResearch = "",
RequiredSubSystems = "Research",
Cost = 1000,
Time = 100,
DisplayedName = "CorvetteTech",
DisplayPriority = 5,
Description = "CorvetteTech",
TargetType = Family,
TargetName = "Corvette",
Icon = Icon_Tech,
ShortDisplayedName = "CorvetteTech", },
{
Name = "DestroyerTech",
RequiredResearch = "",
RequiredSubSystems = "Research",
Cost = 2000,
Time = 150,
DisplayedName = "DestroyerTech",
DisplayPriority = 10,
Description = "DestroyerTech",
TargetType = Family,
TargetName = "Capital",
Icon = Icon_Tech,
ShortDisplayedName = "DestroyerTech", },
{
Name = "AssaultCorvetteTech",
RequiredResearch = "CorvetteTech",
RequiredSubSystems = "Research",
Cost = 2000,
Time = 100,
DisplayedName = "AssaultCorvetteTech",
DisplayPriority = 15,
Description = "AssaultCorvetteTech",
TargetType = Family,
TargetName = "Corvette",
Icon = Icon_Tech,
ShortDisplayedName = "AssaultCorvetteTech", },
{
Name = "BomberCorvetteTech",
RequiredResearch = "CorvetteTech",
RequiredSubSystems = "Research",
Cost = 2000,
Time = 150,
DisplayedName = "BomberCorvetteTech",
DisplayPriority = 20,
Description = "BomberCorvetteTech",
TargetType = Family,
TargetName = "Corvette",
Icon = Icon_Tech,
ShortDisplayedName = "BomberCorvetteTech", },
{
Name = "FrigateTech",
RequiredResearch = "",
RequiredSubSystems = "Research",
Cost = 2500,
Time = 250,
DisplayedName = "FrigateTech",
DisplayPriority = 25,
Description = "FrigateTech",
TargetType = Family,
TargetName = "Frigate",
Icon = Icon_Tech,
ShortDisplayedName = "FrigateTech", },
{
Name = "ShipyardTech",
RequiredResearch = "",
RequiredSubSystems = "Research",
Cost = 2500,
Time = 100,
DisplayedName = "ShipyardTech",
DisplayPriority = 30,
Description = "ShipyardTech",
TargetType = Family,
TargetName = "Capital",
Icon = Icon_Tech,
ShortDisplayedName = "ShipyardTech", },
{
Name = "BattleCruiserTech",
RequiredResearch = "",
RequiredSubSystems = "Research",
Cost = 3000,
Time = 200,
DisplayedName = "BattleCruiserTech",
DisplayPriority = 35,
Description = "BattleCruiserTech",
TargetType = Family,
TargetName = "Capital",
Icon = Icon_Tech,
ShortDisplayedName = "BattleCruiserTech", },
}
шипы выкладывать не буду =/ уж больно много . терь ИИ
classdef.lua
Code:
-- =============================================================================
-- Homeworld 2 Clean Data Resource Project
-- By S110
-- Version 1.0
-- 02/06/2010
-- Tools used: EditPad Lite, LuaDC version 0.9.19, and Cold Fusion LUA Decompiler v1.0.0
-- =============================================================================
aitrace("CPU: CLASSDEF LOADED")
squadclass = {}
squadclass[eMotherShip] = {
HGN_MOTHERSHIP,
VGR_MOTHERSHIP,
VGR_MOTHERSHIP_MAKAAN}
squadclass[eCollector] = {
HGN_RESOURCECOLLECTOR,
TBR_RESOURCECOLLECTOR,
VGR_RESOURCECOLLECTOR}
squadclass[eScout] = {
HGN_SCOUT,
HGN_PROBE,
HGN_PROXIMITYSENSOR,
HGN_ECMPROBE,
VGR_SCOUT,
VGR_PROBE,
VGR_PROBE_PROX,
TBR_SCOUT,
TBR_PROBE,
VGR_PROBE_ECM}
squadclass[eRefinery] = {
HGN_RESOURCECONTROLLER,
TBR_RESOURCECONTROLLER,
VGR_RESOURCECONTROLLER}
squadclass[eBuilder] = {
HGN_MOTHERSHIP,
HGN_CARRIER,
HGN_SHIPYARD,
VGR_MOTHERSHIP,
VGR_MOTHERSHIP_MAKAAN,
VGR_CARRIER,
TBR_CARRIER,
TBR_SHIPYARD,
VGR_SHIPYARD}
squadclass[eDropOff] = {
HGN_MOTHERSHIP,
HGN_CARRIER,
HGN_SHIPYARD,
HGN_RESOURCECONTROLLER,
VGR_MOTHERSHIP,
VGR_MOTHERSHIP_MAKAAN,
VGR_CARRIER,
VGR_SHIPYARD,
TBR_RESOURCECONTROLLER,
TBR_CARRIER,
TBR_SHIPYARD,
VGR_RESOURCECONTROLLER}
squadclass[eSalvageDropOff] = {
HGN_MOTHERSHIP,
HGN_CARRIER,
HGN_SHIPYARD,
VGR_MOTHERSHIP,
VGR_MOTHERSHIP_MAKAAN,
VGR_CARRIER,
TBR_SHIPYARD,
TBR_CARRIER,
VGR_SHIPYARD}
squadclass[eFighter] = {
HGN_INTERCEPTOR,
HGN_ATTACKBOMBER,
HGN_ATTACKBOMBERELITE,
VGR_INTERCEPTOR,
VGR_BOMBER,
TBR_INTERCEPTOR,
TBR_BOMBER,
VGR_LANCEFIGHTER}
squadclass[eCorvette] = {
HGN_ASSAULTCORVETTE,
HGN_PULSARCORVETTE,
HGN_MINELAYERCORVETTE,
VGR_MISSILECORVETTE,
VGR_LASERCORVETTE,
VGR_MINELAYERCORVETTE,
TBR_ASSAULTCORVETTE,
TBR_BOMBERCORVETTE,
VGR_COMMANDCORVETTE}
squadclass[eFrigate] = {
HGN_ASSAULTFRIGATE,
HGN_DEFENSEFIELDFRIGATE,
HGN_IONCANNONFRIGATE,
HGN_MARINEFRIGATE,
HGN_MARINEFRIGATE_SOBAN,
HGN_TORPEDOFRIGATE,
HGN_TORPEDOFRIGATEELITE,
VGR_ASSAULTFRIGATE,
VGR_HEAVYMISSILEFRIGATE,
TBR_LIGHTMISSILEFRIGATE,
VGR_INFILTRATORFRIGATE}
squadclass[eCapture] = {
HGN_MARINEFRIGATE,
HGN_MARINEFRIGATE_SOBAN,
VGR_INFILTRATORFRIGATE}
squadclass[eShield] = {
HGN_DEFENSEFIELDFRIGATE}
squadclass[ePlatform] = {
HGN_GUNTURRET,
HGN_IONTURRET,
VGR_WEAPONPLATFORM_GUN,
VGR_WEAPONPLATFORM_MISSILE,
TBR_IONTURRET,
VGR_HYPERSPACE_PLATFORM}
squadclass[eAntiFighter] = {
HGN_INTERCEPTOR,
HGN_ASSAULTCORVETTE,
HGN_ASSAULTFRIGATE,
HGN_GUNTURRET,
VGR_INTERCEPTOR,
VGR_ASSAULTFRIGATE,
TBR_INTERCEPTOR,
TBR_LIGHTMISSILEFRIGATE,
TBR_ASSAULTCORVETTE,
VGR_WEAPONPLATFORM_GUN}
squadclass[eAntiCorvette] = {
HGN_PULSARCORVETTE,
HGN_TORPEDOFRIGATE,
HGN_TORPEDOFRIGATEELITE,
HGN_DESTROYER,
VGR_LANCEFIGHTER,
VGR_LAZERCORVETTE,
TBR_ASSAULTCORVETTE,
TBR_BOMBERCORVETTE,
TBR_BOMBER,
TBR_LIGHTMISSILEFRIGATE,
TBR_DESTROYER,
VGR_DESTROYER}
squadclass[eAntiFrigate] = {
HGN_IONTURRET,
HGN_ATTACKBOMBER,
HGN_ATTACKBOMBERELITE,
HGN_IONCANNONFRIGATE,
HGN_MARINEFRIGATE,
HGN_MARINEFRIGATE_SOBAN,
HGN_DEFENSEFIELDFRIGATE,
HGN_DESTROYER,
HGN_BATTLECRUISER,
VGR_BOMBER,
VGR_HEAVYMISSILEFRIGATE,
VGR_INFILTRATORFRIGATE,
VGR_DESTROYER,
VGR_BATTLECRUISER,
TBR_DESTROYER,
TBR_BATTLECRUISER,
TBR_BOMBER,
TBR_BOMBERCORVETTE,
VGR_WEAPONPLATFORM_MISSILE}
squadclass[eCapital] = {
HGN_CARRIER,
HGN_MOTHERSHIP,
HGN_SHIPYARD,
HGN_DESTROYER,
HGN_BATTLECRUISER,
HGN_DREADNAUGHT,
VGR_CARRIER,
VGR_MOTHERSHIP,
VGR_MOTHERSHIP_MAKAAN,
VGR_SHIPYARD,
VGR_DESTROYER,
TBR_DESTROYER,
TBR_BATTLECRUISER,
TBR_CARRIER,
TBR_SHIPYARD,
VGR_BATTLECRUISER}
squadclass[eNonThreat] = {
HGN_RESOURCECOLLECTOR,
VGR_RESOURCECOLLECTOR,
HGN_RESOURCECONTROLLER,
VGR_RESOURCECONTROLLER,
HGN_CARRIER,
HGN_MOTHERSHIP,
HGN_SHIPYARD,
VGR_CARRIER,
VGR_MOTHERSHIP,
VGR_MOTHERSHIP_MAKAAN,
VGR_SHIPYARD,
HGN_SCOUT,
HGN_PROBE,
HGN_PROXIMITYSENSOR,
HGN_ECMPROBE,
VGR_SCOUT,
VGR_PROBE,
VGR_PROBE_PROX,
VGR_PROBE_ECM,
TBR_PROBE,
TBR_SCOUT,
TBR_RESOURCECOLLECTOR,
TBR_RESOURCECONTROLLER,
VGR_HYPERSPACE_PLATFORM}
squadclass[eHyperspaceGate] = {
VGR_HYPERSPACE_PLATFORM}
squadclass[eSubSystemAttackers] = {
HGN_ATTACKBOMBER,
HGN_ATTACKBOMBERELITE,
TBR_BOMBER,
TBR_BOMBERCORVETTE,
VGR_BOMBER}
squadclass[eNonCriticalSubSys] = {
CLOAKGENERATOR,
FIRECONTROLTOWER,
HYPERSPACEINHIBITOR,
ADVANCEDARRAY,
CLOAKSENSOR}
squadclass[eGoodRepairAttackers] = {
HGN_INTERCEPTOR,
HGN_ASSAULTFRIGATE,
HGN_IONCANNONFRIGATE,
HGN_DESTROYER,
HGN_BATTLECRUISER,
VGR_INTERCEPTOR,
VGR_MISSILECORVETTE,
VGR_ASSAULTFRIGATE,
VGR_DESTROYER,
TBR_DESTROYER,
TBR_BATTLECRUISER,
TBR_INTERCEPTOR,
TBR_ASSAULTCORVETTE,
TBR_LIGHTMISSILEFRIGATE,
VGR_BATTLECRUISER}
eUselessShips = eMaxCount
eBattleCruiser = eMaxCount + 1
sg_maxClasses = eBattleCruiser + 1
squadclass[eUselessShips] = {
HGN_MINELAYERCORVETTE,
VGR_MINELAYERCORVETTE,
VGR_COMMANDCORVETTE}
squadclass[eBattleCruiser] = {
HGN_BATTLECRUISER,
TBR_BATTLECRUISER,
VGR_BATTLECRUISER}
function FastAddToClass(tbl, classid)
for a, b in tbl do
AddToClass(b, classid)
end
end
function ClassInitialize()
for i=0, sg_maxClasses do
if (squadclass[i]) then
FastAddToClass(squadclass[i], i)
end
end
AddClassName(eMotherShip, "Motherships")
AddClassName(eCollector, "Collectors")
AddClassName(eDropOff, "DropOffs")
AddClassName(eFighter, "Fighters")
AddClassName(eFrigate, "Frigates")
AddClassName(eCorvette, "Corvettes")
AddClassName(eCapital, "Capital")
AddClassName(eAntiFighter, "AntiFighter")
AddClassName(eAntiCorvette, "AntiCorvette")
AddClassName(eAntiFrigate, "AntiFrigate")
AddClassName(ePlatform, "Platform")
AddClassName(eRefinery, "Refinery")
AddClassName(eHyperspaceGate, "HypGates")
AddClassName(eShield, "Shields")
AddClassName(eCapture, "Capture")
AddClassName(eSubSystemAttackers, "SubSysKillas")
AddClassName(eBattleCruiser, "BattleCruiser")
end
cpubuild.lua
Code:
-- =============================================================================
-- Homeworld 2 Clean Data Resource Project
-- By S110
-- Version 1.0
-- 02/06/2010
-- Tools used: EditPad Lite, LuaDC version 0.9.19, and Cold Fusion LUA Decompiler v1.0.0
-- =============================================================================
aitrace("LOADING CPU BUILD")
dofilepath("data:ai/cpuresource.lua")
dofilepath("data:ai/cpubuildsubsystem.lua")
function CreateBuildDefinitions()
if (s_race == Race_Hiigaran) then
kCollector = HGN_RESOURCECOLLECTOR
kRefinery = HGN_RESOURCECONTROLLER
kScout = HGN_SCOUT
kInterceptor = HGN_INTERCEPTOR
kBomber = HGN_ATTACKBOMBER
kCarrier = HGN_CARRIER
kShipYard = HGN_SHIPYARD
kDestroyer = HGN_DESTROYER
kBattleCruiser = HGN_BATTLECRUISER
elseif (s_race == Race_Vaygr) then
kCollector = VGR_RESOURCECOLLECTOR
kRefinery = VGR_RESOURCECONTROLLER
kScout = VGR_SCOUT
kInterceptor = VGR_INTERCEPTOR
kBomber = VGR_BOMBER
kCarrier = VGR_CARRIER
kShipYard = VGR_SHIPYARD
kDestroyer = VGR_DESTROYER
kBattleCruiser = VGR_BATTLECRUISER
else
kCollector = TBR_RESOURCECOLLECTOR
kRefinery = TBR_RESOURCECONTROLLER
kScout = TBR_SCOUT
kInterceptor = TBR_INTERCEPTOR
kBomber = TBR_BOMBER
kCarrier = TBR_CARRIER
kShipYard = TBR_SHIPYARD
kDestroyer = TBR_DESTROYER
kBattleCruiser = TBR_BATTLECRUISER
end
end
function CpuBuild_PersonalityDemand()
if (s_race == Race_Hiigaran) then
sg_classPersonalityDemand[eFighter] = 0.5
sg_classPersonalityDemand[eCorvette] = 0.25
sg_classPersonalityDemand[eFrigate] = 0
elseif (s_race == Race_Vaygr) then
sg_classPersonalityDemand[eFighter] = 0.5
sg_classPersonalityDemand[eCorvette] = 0.5
sg_classPersonalityDemand[eFrigate] = 0.25
else
sg_classPersonalityDemand[eFighter] = 0.5
sg_classPersonalityDemand[eCorvette] = 0.5
sg_classPersonalityDemand[eFrigate] = 0.25
end
sg_classPersonalityDemand[ePlatform] = -0.5
if (Rand(100) < 10) then
sg_classPersonalityDemand[ePlatform] = 0
end
if (g_LOD >= 2) then
sg_classPersonalityDemand[ePlatform] = sg_classPersonalityDemand[ePlatform] - 3
end
aitrace("PersonalityDemand: Fi:"..sg_classPersonalityDemand[eFighter].." Co:"..sg_classPersonalityDemand[eCorvette].." Fr:"..sg_classPersonalityDemand[eFrigate])
end
function CpuBuild_Init()
CreateBuildDefinitions()
CpuBuildSS_Init()
CpuResource_Init()
sg_resourceDemand = 1
sg_scoutDemand = 0
sg_militaryDemand = 1
sg_randScoutStartBuildTime = 30 + Rand(120)
sg_randFavorShipType = Rand(100)
sg_classPersonalityDemand = {}
CpuBuild_PersonalityDemand()
sg_subSystemOverflowDemand = 0
sg_subSystemDemand = 0
sg_shipDemand = 4
sg_militaryToBuildPerCollector = 0
if (g_LOD == 0) then
CpuBuild_DefaultShipDemandRules = CpuBuild_DefaultShipDemandRules_Easy
elseif (g_LOD == 1) then
CpuBuild_DefaultShipDemandRules = CpuBuild_DefaultShipDemandRules_Med
else
CpuBuild_DefaultShipDemandRules = CpuBuild_DefaultShipDemandRules_Hard
end
cp_shipDemandRange = 0.5
cp_subSystemDemandRange = 0.5
if (g_LOD == 1) then
cp_shipDemandRange = 1
cp_subSystemDemandRange = 1
end
if (g_LOD == 0) then
cp_shipDemandRange = 2
cp_subSystemDemandRange = 2
end
if (Override_BuildDemandInit) then
Override_BuildDemandInit()
end
kUnitCapId_Fighter = GetUnitCapFamilyId("Fighter")
kUnitCapId_Corvette = GetUnitCapFamilyId("Corvette")
kUnitCapId_Frigate = GetUnitCapFamilyId("Frigate")
end
function DetermineClassDemand()
for i = 0, eMaxCount do
if (sg_classPersonalityDemand[i] and sg_classPersonalityDemand[i] ~= 0) then
ShipDemandSetByClass(i, sg_classPersonalityDemand[i]);
end
end
ShipDemandSetByClass(eUselessShips, -10)
end
function DetermineAntiChassisDemand(enemyIndex)
local kFighterCounterScale = 3
local kCorvetteCounterScale = 1.5
local kFrigateCounterScale = 1
local AFiDemand = 0
local ACoDemand = 0
local AFrDemand = 0
local FiValue = PlayersMilitary_Fighter(enemyIndex, player_max)
local self_AFiValue = PlayersMilitary_AntiFighter(s_playerIndex, player_max)
local enemy_FiTotal = (FiValue - self_AFiValue) * kFighterCounterScale
if (enemy_FiTotal < 0) then
enemy_FiTotal = 0
end
local CoValue = PlayersMilitary_Corvette(enemyIndex, player_max)
local self_ACoValue = PlayersMilitary_AntiCorvette(s_playerIndex, player_max)
local enemy_CoTotal = (CoValue - self_ACoValue) * kCorvetteCounterScale
if (enemy_CoTotal < 0) then
enemy_CoTotal = 0
end
local MSfrig_correction = 0
if (s_militaryStrengthVersusTarget < 20) then
MSfrig_correction = 25
end
local FrValue = PlayersMilitary_Frigate(enemyIndex, player_max) - MSfrig_correction
local self_AFrValue = PlayersMilitary_AntiFrigate(s_playerIndex, player_max)
local enemy_FrTotal = (FrValue - self_AFrValue) * kFrigateCounterScale
if (enemy_FrTotal < 0) then
enemy_FrTotal = 0
end
local enemy_ChassisTotal = enemy_FiTotal + enemy_CoTotal + enemy_FrTotal
if (enemy_ChassisTotal > 0) then
if (enemy_FiTotal > 0) then
local FiTotalPercent = enemy_FiTotal * 100 / enemy_ChassisTotal
if (FiTotalPercent > 70) then
AFiDemand = AFiDemand + 3
elseif (FiTotalPercent > 35) then
AFiDemand = AFiDemand + 1.5
end
end
if (enemy_CoTotal > 0) then
local CoTotalPercent = enemy_CoTotal * 100 / enemy_ChassisTotal
if (CoTotalPercent > 70) then
ACoDemand = ACoDemand + 3
elseif (CoTotalPercent > 35) then
ACoDemand = ACoDemand + 1.5
end
end
if (enemy_FrTotal > 0) then
local FrTotalPercent = enemy_FrTotal * 100 / enemy_ChassisTotal
if (FrTotalPercent > 70) then
AFrDemand = AFrDemand + 3
elseif (FrTotalPercent > 35) then
AFrDemand = AFrDemand + 1.5
end
end
end
if (AFiDemand > 0) then
ShipDemandAddByClass(eAntiFighter, AFiDemand)
end
if (ACoDemand > 0) then
ShipDemandAddByClass(eAntiCorvette, ACoDemand)
end
if (AFrDemand > 0) then
ShipDemandAddByClass(eAntiFrigate, AFrDemand)
end
aitrace("AChDmd: AFi:"..AFiDemand.." ACo:"..ACoDemand.." AFr:"..AFrDemand)
end
function DetermineChassisDemand(enemyIndex)
local FiDemand = 0
local CoDemand = 0
local FrDemand = 0
local AFiValue = PlayersMilitary_AntiFighter(enemyIndex, player_max)
local ACoValue = PlayersMilitary_AntiCorvette(enemyIndex, player_max)
local AFrValue = PlayersMilitary_AntiFrigate(enemyIndex, player_max)
local ATotal = AFiValue + ACoValue + AFrValue
if (ATotal <= 0) then
return
end
if (AFiValue > 5) then
local AFiPercent = AFiValue * 100 / ATotal
if (AFiPercent > 70) then
FiDemand = FiDemand - 3
elseif (AFiPercent > 35) then
FiDemand = FiDemand - 1.5
end
end
if (ACoValue > 5) then
local ACoPercent = ACoValue * 100 / ATotal
if (ACoPercent > 70) then
CoDemand = CoDemand - 2
elseif (ACoPercent > 35) then
CoDemand = CoDemand - 1
end
end
if (AFrValue > 5) then
local AFrPercent = AFrValue * 100 / ATotal
if (AFrPercent > 70) then
FrDemand = FrDemand - 1.5
elseif (AFrPercent > 35) then
FrDemand = FrDemand - 0.5
end
end
ShipDemandAddByClass(eFighter, FiDemand)
ShipDemandAddByClass(eCorvette, CoDemand)
ShipDemandAddByClass(eFrigate, FrDemand)
aitrace("ChDmd: Fi:"..FiDemand.." Co:"..CoDemand.." Fr:"..FrDemand)
end
function DetermineDemandWithNoCounterInfo()
if (s_militaryPop < 5) then
aitrace("Dmd:Rand:"..sg_randFavorShipType)
if (s_race == Race_Hiigaran) then
if (sg_randFavorShipType < 55) then
ShipDemandAddByClass(eFighter, 1)
elseif (sg_randFavorShipType < 85) then
ShipDemandAddByClass(eCorvette, 1)
elseif (g_LOD < 2 and sg_randFavorShipType < 95) then
ShipDemandAddByClass(eFrigate, 1)
else
ShipDemandAdd(kDestroyer, 1)
end
else
if (sg_randFavorShipType < 45) then
ShipDemandAddByClass(eFighter, 1)
elseif (sg_randFavorShipType < 75) then
ShipDemandAddByClass(eCorvette, 1)
else
ShipDemandAddByClass(eFrigate, 1)
end
end
else
aitrace("Dmd:Asking for AntiFrigates")
ShipDemandAddByClass(eAntiFrigate, 1.5)
end
end
function DetermineCounterDemand()
if (s_enemyIndex ~= -1) then
local enemyMilitaryCount = PlayersMilitaryPopulation(s_enemyIndex, player_max)
if (enemyMilitaryCount >= 3) then
DetermineChassisDemand(s_enemyIndex)
DetermineAntiChassisDemand(s_enemyIndex)
return
end
end
DetermineDemandWithNoCounterInfo();
end
function DetermineSpecialDemand()
if (ShipDemandGet(kInterceptor) > 0 and NumSubSystems(FIGHTERPRODUCTION) > 0 and NumSquadrons(kInterceptor) < 3 and s_militaryPop < 10) then
ShipDemandAdd(kInterceptor, 0.5)
end
if (s_selfTotalValue > 120) then
local additionalFrigDemand = 0.5
if (s_race == Race_Hiigaran) then
local advresearchcount = NumSubSystems(ADVANCEDRESEARCH) + NumSubSystemsQ(ADVANCEDRESEARCH)
if (advresearchcount > 0) then
additionalFrigDemand = additionalFrigDemand + 0.25
end
end
ShipDemandAddByClass(eFrigate, additionalFrigDemand)
ShipDemandAddByClass(eFighter, -0.5)
end
local numSpecial = numQueueOfClass(eCapture) + numQueueOfClass(eShield)
local numFrigates = numQueueOfClass(eFrigate)
if (numFrigates == 0 or numSpecial / numFrigates > 0.4) then
ShipDemandAddByClass(eCapture, -10)
ShipDemandAddByClass(eShield, -10)
else
if (s_militaryPop < 5) then
ShipDemandAddByClass(eCapture, -4)
ShipDemandAddByClass(eShield, -4.5)
elseif (s_militaryPop < 10) then
ShipDemandAddByClass(eCapture, -2)
ShipDemandAddByClass(eShield, -2.5)
elseif (s_militaryPop < 15) then
ShipDemandAddByClass(eCapture, -1)
ShipDemandAddByClass(eShield, -1.5)
elseif (s_militaryPop > 30) then
ShipDemandAddByClass(eCapture, 1)
ShipDemandAddByClass(eShield, 1)
end
end
if (s_race == Race_Hiigaran) then
local torpedoDemand = -0.5
if (IsResearchDone(IMPROVEDTORPEDO) == 1 or s_militaryStrength > 40 or GetRU() > 2500) then
torpedoDemand = 0
end
ShipDemandAdd(HGN_TORPEDOFRIGATE, torpedoDemand)
end
local numRUs = GetRU()
if ((GetNumCollecting() > 9 or numRUs > 1500) and s_militaryPop > 8 and UnderAttackThreat() < -75) then
ShipDemandAdd(kBattleCruiser, 0.75)
ShipDemandAdd(kDestroyer, 0.25)
if (IsResearchDone(BATTLECRUISERIONWEAPONS) == 1) then
ShipDemandAdd(kBattleCruiser, 0.5)
end
end
local numEnemyBattleCruisers = PlayersUnitTypeCount(player_enemy, player_total, eBattleCruiser)
if (numEnemyBattleCruisers > 0) then
local ssKillaDemand = numEnemyBattleCruisers / 2
if (s_enemyIndex ~= -1) then
local targetEnemyCruisers = PlayersUnitTypeCount(s_enemyIndex, player_max, eBattleCruiser)
if (targetEnemyCruisers > 0) then
ssKillaDemand = ssKillaDemand + targetEnemyCruisers
end
end
ShipDemandAddByClass(eSubSystemAttackers, ssKillaDemand)
end
local numShipyards = NumSquadrons(kShipYard) + NumSquadronsQ(kShipYard)
if (numShipyards == 0 and UnderAttackThreat() < -75) then
local bcDemand = ShipDemandGet(kBattleCruiser)
if (bcDemand >= 0.5) then
ShipDemandAdd(kShipYard, bcDemand - 0.5)
end
end
if (s_militaryStrength > 25 * sg_moreEnemies) then
ShipDemandAddByClass(ePlatform, -2)
end
end
function CalculateMilitaryValueGoal(militaryTable, percentOfEnemy)
local curTime = gameTime()
local minMilitaryValue = 0
if (s_enemyTotalValue * percentOfEnemy > minMilitaryValue) then
minMilitaryValue = s_enemyTotalValue * percentOfEnemy
end
for k, v in militaryTable do
if (curTime < v[3]) then
if (minMilitaryValue < v[1]) then
minMilitaryValue = v[1]
end
if (minMilitaryValue > v[2]) then
minMilitaryValue = v[2]
end
break
end
end
return minMilitaryValue
end
function CpuBuild_DefaultShipDemandRules_Easy()
local valueTable = {
{80, 135, 8 * 60},
{120, 180, 15 * 60},
{160, 230, 20 * 60},
{220, 300, 30 * 60},
{270, 370, 45 * 60},
{350, 500, 60 * 60},
{500, 1000, 10000 * 60},}
local minMilitaryValue = CalculateMilitaryValueGoal(valueTable, 0.7)
aitrace("Aim:"..minMilitaryValue.." CurMil:"..s_selfTotalValue.." Enm:"..s_enemyTotalValue)
if (s_selfTotalValue < minMilitaryValue) then
DetermineClassDemand();
DetermineCounterDemand();
DetermineSpecialDemand();
end
DetermineScoutDemand();
DetermineBuilderClassDemand();
end
function CpuBuild_DefaultShipDemandRules_Med()
local valueTable = {
{120, 200, 8 * 60},
{160, 250, 15 * 60},
{220, 320, 20 * 60},
{280, 400, 30 * 60},
{320, 500, 45 * 60},
{500, 700, 60 * 60},
{700, 1200, 10000 * 60},}
local minMilitaryValue = CalculateMilitaryValueGoal(valueTable, 0.85)
aitrace("Aim:"..minMilitaryValue.." CurMil:"..s_selfTotalValue.." Enm:"..s_enemyTotalValue)
if (s_selfTotalValue < minMilitaryValue) then
DetermineClassDemand();
DetermineCounterDemand();
DetermineSpecialDemand();
end
DetermineScoutDemand();
DetermineBuilderClassDemand();
end
function CpuBuild_DefaultShipDemandRules_Hard()
DetermineClassDemand();
DetermineCounterDemand();
DetermineScoutDemand();
DetermineBuilderClassDemand();
DetermineSpecialDemand();
end
function CpuBuild_RemoveBuildItems()
RemoveStalledBuildItems()
end
function CpuBuild_Process()
ShipDemandClear()
CpuBuild_RemoveBuildItems()
if (Override_ShipDemand) then
Override_ShipDemand()
else
CpuBuild_DefaultShipDemandRules()
end
if (sg_resourceDemand > 0 or sg_militaryDemand <= 0) then
if (DoResourceBuild() == 1) then
sg_resourceDemand = 1 - sg_militaryToBuildPerCollector
return 1
end
end
if (sg_militaryDemand > 0) then
aitrace("**DoMilitaryBuild")
if (DoMilitaryBuild() == 1) then
if (sg_resourceDemand <= 0) then
sg_resourceDemand = sg_resourceDemand + 1
end
return 1
end
end
return 0
end
function DoMilitaryBuild()
local ssDemand = sg_subSystemDemand + sg_subSystemOverflowDemand + (Rand(3) - 1)
local shipId = FindHighDemandShip()
local highestPriority = HighestPriorityShip()
if (UnderAttackThreat() > -5 and shipId > 0 and highestPriority >= 0.5) then
ssDemand = 0
aitrace("Subsys demand reduced because we are under attack")
end
if (sg_shipDemand > ssDemand) then
if (shipId > 0) then
Build(shipId)
sg_subSystemOverflowDemand = sg_subSystemOverflowDemand + 1
return 1
end
end
if (sg_dosubsystems == 1 and CpuBuildSS_DoBuildSubSystem() == 1) then
return 1
end
return 0
end
function DetermineScoutDemand()
local curGameTime = gameTime()
if (UnderAttackThreat() < -10 and s_militaryPop > 0 and curGameTime > sg_randScoutStartBuildTime) then
local numEnemies = PlayersAlive(player_enemy)
local shipCount = numQueueOfClass(eScout)
local numScoutsDemanded = 1
if (numEnemies >= 2) then
numScoutsDemanded = 2
end
if (numEnemies > 2 and s_militaryPop > 7) then
numScoutsDemanded = 2 + ((s_militaryPop - 7) / 10)
end
if (shipCount < numScoutsDemanded) then
ShipDemandAddByClass(eScout, 3.5)
local scoutRand = Rand(100)
if (scoutRand > 30) then
ShipDemandAdd(kScout, 1.5)
end
sg_randScoutStartBuildTime = curGameTime + 50
end
end
end
function DetermineBuilderClassDemand()
local numBuilders = numQueueOfClass(eBuilder)
local numActiveBuilders = numActiveOfClass(s_playerIndex, eBuilder)
if (numBuilders > numActiveBuilders) then
ShipDemandAddByClass(eBuilder, -10);
return
end
if (g_LOD == 0 and numBuilders > 3) then
ShipDemandAddByClass(eBuilder, -10);
return
elseif (g_LOD == 1 and numBuilders > 4) then
ShipDemandAddByClass(eBuilder, -10);
return
end
if (s_militaryPop < 5 or (UnderAttack() == 1 and UnderAttackThreat() > -75)) then
ShipDemandAddByClass(eBuilder, -10);
return
end
local numRUs = GetRU()
if (GetNumCollecting() < 7 and numRUs < 15000) then
return
end
local numRUToBuildTable = {1000, 2000, 3500, 6500, 10000, 15000}
if (numBuilders > 5) then
numBuilders = 5
end
local RUsNeededToBuildBuilder = numRUToBuildTable[numBuilders + 1]
if (s_race == Race_Vaygr) then
RUsNeededToBuildBuilder = RUsNeededToBuildBuilder - 500
end
local dif = numRUs - RUsNeededToBuildBuilder
if (dif > 0) then
local ruPerShip = 2000
if (s_militaryStrength > 30) then
ruPerShip = 1000
end
local bonusDemand = (1 + (dif / ruPerShip))
ShipDemandAddByClass(eBuilder, bonusDemand);
end
if (dif < -2000) then
local penaltyDemand = dif / 2000
ShipDemandAddByClass(eBuilder, penaltyDemand);
end
local neededMilitaryValue = 30 + (numBuilders - 1) * 60
local militaryDifDemand = (s_selfTotalValue - neededMilitaryValue) / 30
if (militaryDifDemand < 0) then
ShipDemandAddByClass(eBuilder, militaryDifDemand);
end
return 0
end
щас еще.. а то комп ща сгорит х_х
cpubuildsubsystem.lua
Code:
-- =============================================================================
-- Homeworld 2 Clean Data Resource Project
-- By S110
-- Version 1.0
-- 02/06/2010
-- Tools used: EditPad Lite, LuaDC version 0.9.19, and Cold Fusion LUA Decompiler v1.0.0
-- =============================================================================
function CpuBuildSS_Init()
if (s_race == Race_Hiigaran) then
CpuBuildSS_DefaultSubSystemDemandRules = DoSubSystemDemand_Hiigaran
elseif (s_race == Race_Vaygr) then
CpuBuildSS_DefaultSubSystemDemandRules = DoSubSystemDemand_Vaygr
else
CpuBuildSS_DefaultSubSustemDemandRules = DoSubSystemDemand_Tobari
end
sg_lastSpecialSubSysTime = 0
sg_specialSubSysDelayTime = 150 + Rand(100)
sg_retireCountCheck = 0
sg_buildBCHyperspace = 1
end
function CpuBuildSS_SpecialSubSystemDemand()
local curGameTime = gameTime()
local timeSinceLastSubSysDemand = curGameTime - sg_lastSpecialSubSysTime
if (s_selfTotalValue > 160 and s_militaryStrength > -5 and UnderAttackThreat() < -70 and (timeSinceLastSubSysDemand > sg_specialSubSysDelayTime or GetRU() > 3000)) then
local productionDemand = SubSystemDemandGet(FIGHTERPRODUCTION) +
SubSystemDemandGet(CORVETTEPRODUCTION) +
SubSystemDemandGet(FRIGATEPRODUCTION) +
SubSystemDemandGet(CAPSHIPPRODUCTION) +
SubSystemDemandGet(PLATFORMPRODUCTION) +
SubSystemDemandGet(RESEARCH) +
SubSystemDemandGet(ADVANCEDRESEARCH)
aitrace("SS:special demand:"..productionDemand)
if (productionDemand <= 1) then
local specialSubsystems = {HYPERSPACE, FIRECONTROLTOWER, HYPERSPACEINHIBITOR}
if (g_LOD < 2) then
specialSubsystems = {HYPERSPACE, CLOAKGENERATOR, FIRECONTROLTOWER, HYPERSPACEINHIBITOR, ADVANCEDARRAY, CLOAKSENSOR}
end
local minNumber = 10
local maxNumber = 0
for a, b in specialSubsystems do
local numberBuilt = NumSubSystems(b) + NumSubSystemsQ(b)
if (numberBuilt < minNumber) then
minNumber = numberBuilt
end
if (numberBuilt > maxNumber) then
maxNumber = numberBuilt
end
end
for a, b in specialSubsystems do
local numQueued = NumSubSystemsQ(b)
if (numQueued == 0) then
local numberBuilt = NumSubSystems(b) + numQueued
local demand = 1
if (minNumber < maxNumber) then
demand = demand * (1.0 - ((numberBuilt - minNumber) / (maxNumber - minNumber)))
end
SubSystemDemandAdd(b, demand)
end
end
sg_lastSpecialSubSysTime = curGameTime;
end
end
end
function CpuBuildSS_RetireVaygrProductionSubSystems()
local numCarriers = CarrierCount()
for i = 0, (numCarriers - 1) do
local carrier = CarrierAt(i)
local productionId = CarrierProductionSubSystem(carrier)
if (productionId ~= 0) then
local ssdemand = SubSystemDemandGet(productionId)
if (ssdemand < 0) then
sg_retireCountCheck = sg_retireCountCheck + 1
if (sg_retireCountCheck >= 2) then
aitrace("VaygrCarrierRetire: Dem:"..ssdemand.." Count:"..sg_retireCountCheck)
RetireSubSystem(carrier, productionId)
sg_retireCountCheck = 0
return
end
else
sg_retireCountCheck = 0
end
end
end
end
function std_minTuple(a, b, c)
local minsubs = a
if (b < minsubs) then
minsubs = b
end
if (c < minsubs) then
minsubs = c
end
return minsubs
end
function std_maxTuple(a, b, c)
local maxsubs = a
if (b > maxsubs) then
maxsubs = b
end
if (c > maxsubs) then
maxsubs = c
end
return maxsubs
end
function CpuBuildSS_ProcessEachBuildShip()
local bcount = BuildShipCount()
if (bcount == 0) then
return 0
end
if (s_totalProdSS == 0) then
return 0
end
aitrace("NumSS:Fi:"..s_numFiSystems.." Co:"..s_numCoSystems.." Fr:"..s_numFrSystems)
local currentFiDemand = SubSystemDemandGet(FIGHTERPRODUCTION)
local currentCoDemand = SubSystemDemandGet(CORVETTEPRODUCTION)
local currentFrDemand = SubSystemDemandGet(FRIGATEPRODUCTION)
local maxRealDemand = std_maxTuple(currentFiDemand, currentCoDemand, currentFrDemand)
local highestPrioritySSOverall = HighestPrioritySubSystem()
aitrace("SS:Fi:"..currentFiDemand.." Co:"..currentCoDemand.." Fr:"..currentFrDemand)
local minNumSameSubs = std_minTuple(s_numFiSystems, s_numCoSystems, s_numFrSystems)
local fiBuildOffset = ((s_numFiSystems-minNumSameSubs) / bcount) * 3
local coBuildOffset = ((s_numCoSystems-minNumSameSubs) / bcount) * 3
local frBuildOffset = ((s_numFrSystems-minNumSameSubs) / bcount) * 3
local bestProdSS = FIGHTERPRODUCTION
local maxDemand = currentFiDemand - fiBuildOffset
aitrace("Maxdemand:"..maxDemand.."MaxReal:"..maxRealDemand)
if ((currentCoDemand - coBuildOffset) > maxDemand) then
maxDemand = currentCoDemand - coBuildOffset
bestProdSS = CORVETTEPRODUCTION
end
if ((currentFrDemand - frBuildOffset) > maxDemand) then
maxDemand = currentFrDemand - frBuildOffset
bestProdSS = FRIGATEPRODUCTION
end
local economicValue = 0
local numCollecting = GetNumCollecting();
local numRU = GetRU()
if (UnderAttack() == 0 or UnderAttackThreat() < -100) then
if ((numRU > (2500 + bcount * 1000) and numCollecting > 8)) then
economicValue = 2
elseif ((numRU > (1000 + bcount * 500) and numCollecting > 6)) then
economicValue = 1
end
end
for i = 0, (bcount - 1) do
local buildShipId = BuildShipAt(i)
if (sg_buildBCHyperspace == 1 and BuildShipType(buildShipId) == kBattleCruiser) then
aitrace("BC:SS")
if (BuildShipHasSubSystem(buildShipId, HYPERSPACE) == 0 and UnderAttackThreat() < -5 and
BuildShipCanBuild(buildShipId, HYPERSPACE) == 1) then
aitrace("Build BC Hyperspace")
BuildSubSystemOnShip(buildShipId, HYPERSPACE)
return 1
end
end
if (highestPrioritySSOverall <= maxRealDemand and maxRealDemand >= 0) then
local hasFi = BuildShipHasSubSystem(buildShipId, FIGHTERPRODUCTION)
local hasCo = BuildShipHasSubSystem(buildShipId, CORVETTEPRODUCTION)
local hasFr = BuildShipHasSubSystem(buildShipId, FRIGATEPRODUCTION)
local sscount = hasFi + hasCo + hasFr
local allowBuild = 0
if (sscount > 0) then
if (sscount == 1 and economicValue > 0) then
allowBuild = 1
aitrace("Scount"..sscount.." Econ:"..economicValue)
elseif (sscount == 2 and economicValue > 1) then
allowBuild = 1
aitrace("Scount"..sscount.." Econ:"..economicValue)
else
local maxDemandOnShip = -1
if (hasFi == 1 and currentFiDemand > maxDemandOnShip) then
maxDemandOnShip = currentFiDemand
end
if (hasCo == 1 and currentCoDemand > maxDemandOnShip) then
maxDemandOnShip = currentCoDemand
end
if (hasFr == 1 and currentFrDemand > maxDemandOnShip) then
maxDemandOnShip = currentFrDemand
end
if (maxDemandOnShip < 0) then
allowBuild = 1
end
aitrace("S"..i.." FiD:"..currentFiDemand.." CoD:"..currentCoDemand.." FrD:"..currentFrDemand)
aitrace("S"..i.." Max:"..maxDemandOnShip)
end
else
allowBuild = 1
end
if (allowBuild == 1) then
if (BuildShipCanBuild(buildShipId, bestProdSS) == 1) then
aitrace("BuildSS in new func")
BuildSubSystemOnShip(buildShipId, bestProdSS)
return 1
end
end
end
end
SubSystemDemandSet(FIGHTERPRODUCTION, -1)
SubSystemDemandSet(CORVETTEPRODUCTION, -1)
SubSystemDemandSet(FRIGATEPRODUCTION, -1)
return 0
end
function CpuBuildSS_DoBuildSubSystem()
SubSystemDemandClear()
if (Override_SubSystemDemand) then
Override_SubSystemDemand()
else
CpuBuildSS_DefaultSubSystemDemandRules()
end
local subSystemId = FindHighDemandSubSystem()
sg_subSystemOverflowDemand = 0
if (s_race == Race_Vaygr) then
CpuBuildSS_RetireVaygrProductionSubSystems()
end
if (subSystemId > 0) then
if (CpuBuildSS_ProcessEachBuildShip() == 1) then
return 1
end
subSystemId = FindHighDemandSubSystem()
if (subSystemId > 0) then
BuildSubSystem(subSystemId)
end
return 1
end
return 0
end
function CpuBuildSS_DoSubSystemProductionDemand(ProductionSubSys, eClasstype, familyid)
local demand = ShipDemandMaxByClass(eClasstype)
local uc = GetUnitCapForFamily(familyid)
local ucMax = GetUnitCapMaxForFamily(familyid)
local ucLeft = ucMax - uc
if (ucLeft < 2) then
demand = demand - 3 + ucLeft
end
if (demand < 0) then
demand = -0.5
end
SubSystemDemandSet(ProductionSubSys, demand)
end
function CpuBuildSS_OtherMiscSubSystemDemand()
local demand = ShipDemandMaxByClass(eBuilder)
local capdemand = ShipDemandMaxByClass(eCapital)
if (capdemand > demand) then
demand = capdemand
end
if (demand > 0.5) then
SubSystemDemandSet(CAPSHIPPRODUCTION, demand - 0.5)
end
if (s_militaryStrength < -50 or g_LOD < 1 or GetRU() > 4000) then
local platformsubsCount = NumSubSystems(PLATFORMPRODUCTION) + NumSubSystemsQ(PLATFORMPRODUCTION)
demand = ShipDemandMaxByClass(ePlatform)
if (demand > 0.5) then
SubSystemDemandSet(PLATFORMPRODUCTION, demand - 1 - platformsubsCount)
end
end
local numShipyards = NumSquadrons(kShipYard)
if (numShipyards == 0) then
local SY_demand = ShipDemandGet(kShipYard)
if (SY_demand > 0 and NumSubSystemsQ(HYPERSPACE) == 0) then
local hypDemand = SY_demand - 0.5 - NumSubSystems(HYPERSPACE)
SubSystemDemandAdd(HYPERSPACE, hypDemand)
end
end
end
function DoSubSystemDemand_Hiigaran()
CpuBuildSS_DoSubSystemProductionDemand(FIGHTERPRODUCTION, eFighter, kUnitCapId_Fighter)
local researchcount = NumSubSystems(RESEARCH) + NumSubSystemsQ(RESEARCH)
local highestCorvetteDemand = ShipDemandMaxByClass(eCorvette)
local highestFrigateDemand = ShipDemandMaxByClass(eFrigate)
local researchdemand = highestCorvetteDemand
local capdemand = ShipDemandMaxByClass(eCapital)
if (highestFrigateDemand > researchdemand) then
researchdemand = highestFrigateDemand
elseif (capdemand > researchdemand) then
researchdemand = capdemand
end
if (researchcount == 0) then
SubSystemDemandSet(RESEARCH, researchdemand + 0.5)
else
CpuBuildSS_DoSubSystemProductionDemand(CORVETTEPRODUCTION, eCorvette, kUnitCapId_Corvette)
CpuBuildSS_DoSubSystemProductionDemand(FRIGATEPRODUCTION, eFrigate, kUnitCapId_Frigate)
local advresearchcount = NumSubSystems(ADVANCEDRESEARCH) + NumSubSystemsQ(ADVANCEDRESEARCH)
local doAdvResearch = 0
local advResDemand = researchdemand
if (s_numFrSystems > 0) then
researchdemand = researchdemand + 0.5
end
if (advresearchcount == 0 and researchdemand >= 0.5 and UnderAttackThreat() < -5 and (s_militaryPop > 8 or s_selfTotalValue > 150 or s_militaryStrength > 50)) then
SubSystemDemandSet(ADVANCEDRESEARCH, researchdemand-0.5)
end
end
CpuBuildSS_OtherMiscSubSystemDemand();
if (researchcount > 0 and s_totalProdSS > 0 and s_militaryPop > 8 and GetNumCollecting() > 8 and GetRU() > 800) then
CpuBuildSS_SpecialSubSystemDemand()
end
end
function DoSubSystemDemand_Vaygr()
CpuBuildSS_DoSubSystemProductionDemand(FIGHTERPRODUCTION, eFighter, kUnitCapId_Fighter)
local researchcount = NumSubSystems(RESEARCH) + NumSubSystemsQ(RESEARCH)
local highestCorvetteDemand = ShipDemandMaxByClass(eCorvette)
local highestFrigateDemand = ShipDemandMaxByClass(eFrigate)
local capdemand = ShipDemandMaxByClass(eCapital)
if (researchcount == 0) then
local researchdemand = highestCorvetteDemand
if (highestFrigateDemand > researchdemand) then
researchdemand = highestFrigateDemand
elseif (capdemand > researchdemand) then
researchdemand = capdemand
end
SubSystemDemandSet(RESEARCH, researchdemand + 1)
end
if (IsResearchDone(CORVETTETECH) == 1) then
CpuBuildSS_DoSubSystemProductionDemand(CORVETTEPRODUCTION, eCorvette, kUnitCapId_Corvette)
end
if (IsResearchDone(FRIGATETECH) == 1) then
CpuBuildSS_DoSubSystemProductionDemand(FRIGATEPRODUCTION, eFrigate, kUnitCapId_Frigate)
end
CpuBuildSS_OtherMiscSubSystemDemand();
if (researchcount > 0 and s_totalProdSS > 0 and s_militaryPop > 8 and GetNumCollecting() > 8 and GetRU() > 800) then
CpuBuildSS_SpecialSubSystemDemand()
end
end
cpumilitary.lua
Code:
-- =============================================================================
-- Homeworld 2 Clean Data Resource Project
-- By S110
-- Version 1.0
-- 02/06/2010
-- Tools used: EditPad Lite, LuaDC version 0.9.19, and Cold Fusion LUA Decompiler v1.0.0
-- =============================================================================
aitrace("LOADING CPU MILITARY")
function CpuMilitary_Init()
cp_attackPercent = 100
if (g_LOD == 0) then
cp_attackPercent = 50
end
cp_minSquadGroupSize = 5
cp_minSquadGroupValue = 200
cp_maxGroupSize = 14
cp_maxGroupValue = 200
cp_forceAttackGroupSize = 14
if (g_LOD == 1) then
cp_forceAttackGroupSize = 12
end
if (g_LOD == 0) then
cp_forceAttackGroupSize = 8
end
cp_initThreatModifier = 0.95
if (g_LOD == 0) then
cp_initThreatModifier = 0.5
elseif (g_LOD == 1) then
cp_initThreatModifier = 0.75
end
sg_moreEnemies = 0
sg_militaryRand = Rand(100)
if (Override_MilitaryInit) then
Override_MilitaryInit()
end
end
function CpuMilitary_Process()
local numEnemies = PlayersAlive(player_enemy)
local numAllies = PlayersAlive(player_ally)
sg_moreEnemies = numEnemies - numAllies
Logic_military_groupvars();
Logic_military_attackrules();
Logic_military_setattacktimer();
end
function Logic_military_groupvars()
cp_minSquadGroupSize = 4
cp_minSquadGroupValue = 150
if (sg_moreEnemies > 0 and s_selfTotalValue < s_enemyTotalValue * 2) then
cp_minSquadGroupSize = cp_minSquadGroupSize + 2
cp_minSquadGroupValue = cp_minSquadGroupValue + 75
else
if (s_militaryStrength > 120) then
cp_minSquadGroupSize = 3
cp_minSquadGroupValue = 120
end
end
end
function Logic_military_attackrules()
if (g_LOD == 0) then
if (gameTime() > 20 * 60 and s_militaryStrength > 0) then
cp_attackPercent = 100
end
if (s_selfTotalValue * 2 < s_enemyTotalValue and s_selfTotalValue > 150) then
cp_attackPercent = 0
aitrace("I'm Losing!! Go on defence")
end
end
end
function attack_now_timer()
aitrace("Script:calling attack_now_timer")
AttackNow();
Rule_Remove("attack_now_timer")
end
function Logic_military_setattacktimer()
local timedelay = 600
local wavedelay = 240 + sg_militaryRand * 0.6
if (g_LOD == 1) then
timedelay = 400
wavedelay = 160 + sg_militaryRand * 0.4
end
if (g_LOD >= 2) then
timedelay = 0
wavedelay = 45 + sg_militaryRand * 0.3
end
local gametime = gameTime()
if (gametime >= timedelay or HaveBeenAttacked() == 1) then
if (Rule_Exists("attack_now_timer") == 0) then
aitrace("Script: Attacktimer added")
Rule_AddInterval("attack_now_timer", wavedelay)
end
end
end
следующий заход =р
Last edited by Хранитель : 03-24-2014 at 06:32 AM.
|