RelicNews Forums

Go Back   RelicNews Forums > RDN - Relic Game Mods > Homeworld 2 - Tanis Shipyards
User Name
Password
Register FAQ Members List Arcade Mark Forums Read



Closed Thread
 
Thread Tools
Old 9th Nov 03, 11:18 PM   # 1
pipakin
Guest
 

ai/default.lua translation :)

default.lua

Code:
-- Default.lua -- Translated by Philip "Pip" Kin -- -- Default AI loop and Setup info aitrace("DEFAULT CPU LOADED") g_LOD = getLevelOfDifficulty() dofilepath("data:ai/classdef.lua") dofilepath("data:ai/cpubuild.lua") dofilepath("data:ai/cpuresearch.lua") dofilepath("data:ai/cpumilitary.lua") --REMed For Correct tracing :) --function aitrace(text) --end function oninit() s_playerIndex = Player_Self() s_race = getRace() sg_dobuild = 1 sg_dosubsystems = 1 sg_doresearch = 1 sg_doupgrades = 1 sg_domilitary = 1 cp_processResource = 1 cp_processMilitary = 1 sg_lastSpendMoneyTime = gameTime() sg_spendMoneyDelay = 0 if g_LOD < 2 then sg_spendMoneyDelay = 4 if g_LOD < 1 then sg_spendMoneyDelay = 8 end end ClassInitialize() CpuBuild_Init() CpuResearch_Init() CpuMilitary_Init() sg_kDemandResetValue = 4 if s_race == Race_Vaygr then sg_kDemandResetValue = 2 end if Override_Init then Override_Init() end sg_researchDemand = -sg_kDemandResetValue Rule_AddInterval("doai", 2) end function CalcOpenBuildChannels() local numShipsBuildingShips = NumShipsBuildingShips() local numShipsBuildingSubSystems = NumShipsBuildingSubSystems() local numShipsBuilding = numShipsBuildingShips + numShipsBuildingSubSystems local researchItem = IsResearchBusy() local numItemsBuilding = numShipsBuilding + researchItem local totalBuildShips = BuildShipCount() * 2 local numCollecting = GetNumCollecting() local numRUs = GetRU() sg_allowedBuildChannels = numCollecting/5 --!!!Global!!! if numRUs > 500 then sg_allowedBuildChannels = sg_allowedBuildChannels + (numRUs - 500)/1000 end s_numOpenBuildChannels = sg_allowedBuildChannels - numItemsBuilding s_shipBuildQueuesFull = 0 if totalBuildShips == numShipsBuilding then s_shipBuildQueuesFull = 1 end if s_numOpenBuildChannels <= 1.5 then RemoveLeastNeededItem() end end function CacheCurrentState() s_numFiSystems = NumSubSystems(FIGHTERPRODUCTION) + NumSubSystemsQ(FIGHTERPRODUCTION) s_numCoSystems = NumSubSystems(CORVETTEPRODUCTION) + NumSubSystemsQ(CORVETTEPRODUCTION) s_numFrSystems = NumSubSystems(FRIGATEPRODUCTION) + NumSubSystemsQ(FRIGATEPRODUCTION) s_totalProdSS = s_numFiSystems + s_numCoSystems + s_numFrSystems s_militaryPop = PlayersMilitaryPopulation(s_playerIndex, player_total) s_selfTotalValue = PlayersMilitary_Total(s_playerIndex, player_total) s_enemyTotalValue = PlayersMilitary_Total(player_enemy, player_max) s_militaryStrength = PlayersMilitary_Threat(player_enemy, player_min) s_enemyIndex = GetChosenEnemy() s_militaryStrengthVersusTarget = 0 if not s_enemyIndex == -1 then s_militaryStrengthVersusTarget = PlayersMilitary_Threat(s_enemyIndex, player_max) end end function SpendMoney() if s_numOpenBuildChannels > 0 then local buildHasBeenDone = 0 if sg_dobuild == 1 then if s_shipBuildQueuesFull == 0 then if sg_researchDemand < 0 then if CpuBuild_Process() == 1 then s_numOpenBuildChannels = s_numOpenBuildChannels - 1 sg_researchDemand = sg_researchDemand + 1 buildHasBeenDone = 1 end end end end if s_numOpenBuildChannels > 0 then if sg_doresearch == 1 then local didResearch = CpuResearch_Process() if didResearch == 1 then sg_researchDemand = -sg_kDemandResetValue else if sg_researchDemand >= 0 then if sg_dobuild == 1 then if s_shipBuildQueuesFull == 0 then if buildHasBeenDone == 0 then CpuBuild_Process() end end end end end else sg_reseachDemand = -sg_kDemandResetValue end end end end function doai() CacheCurrentState() CalcOpenBuildChannels() local curTime = gameTime() local timeSinceLastSubSysDemand = curTime - sg_lastSpendMoneyTime if timeSinceLastSubSysDemand >= sg_spendMoneyDelay then SpendMoney() sg_lastSpendMoneyTime = curTime end if sg_domilitary == 1 then CpuMilitary_Process() end end
 
Old 10th Nov 03, 8:32 AM   # 2
Ragnarokx
Member
 
Join Date: Nov 2003

what exactly is this file good for ? Is it about modding the AI and Build Order or what ? sry....
Ragnarokx is offline Send a message via ICQ to Ragnarokx  
Old 10th Nov 03, 9:07 AM   # 3
starfleet
Guest
 

the ai files control when how etc it will build certain things as mecha put it they don't control it's difficulty but they do stop it building 2 bc's from the start and coming for you right there and then.
 
Old 10th Nov 03, 10:14 AM Forum Rules   # 4
mecha
Relic Entertainment
 
mecha's Avatar
 
Join Date: Sep 2001

Uh, no.

I was talking about the ai<n>.lua files in each level directory which were the files you were asking about.

The files in data/ai/ do control ai, build order, research order, difficulty and such.

This particular file controls default setup of various ai variables used in the code.
mecha is offline  
Old 10th Nov 03, 3:33 PM   # 5
starfleet
Guest
 

Mecha: That stuff there ^^^ is the stuff i've been asking about!!!

ROFL.

Like i said I'd noticed the AI didn't build anything unless added to files here.. so if it does control the ai that means the ai can be changed to do diffrent things within limits *cheers*
 
Closed Thread



Go Back   RelicNews Forums > RDN - Relic Game Mods > Homeworld 2 - Tanis Shipyards
User Name
Password
Register FAQ Members List Arcade Mark Forums Read



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




All times are GMT -7. The time now is 4:57 AM.

Page generated in 0.24048591 seconds (91.32% PHP - 8.68% MySQL) with 9 queries

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.