Resource; Gravwell Demo - HWRM/KarosGraveyard GitHub Wiki
A HW1 style Gravwell demo. Also requires the Defense Field ability to be added to the hiigaran carrier. Beyond that, load it as you would any other gamerules file.
-- LuaDC version 0.9.19
-- 5/23/2004 11:21:45 PM
-- LuaDC by Age2uN
-- on error send source file (compiled lua) and this outputfile to [email protected]
--
GUID =
{ 110, 91, 157, 190, 18, 23, 250, 78, 144, 20, 41, 246, 181, 128, 214, 12, }
GameRulesName = "Gravwell Demo"
Description = "$3230"
GameSetupOptions =
{
{
name = "resources",
locName = "$3240",
tooltip = "$3239",
default = 1,
visible = 1,
choices =
{ "$3241", "0.5", "$3242", "1.0", "$3243", "2.0", }, },
{
name = "unitcaps",
locName = "$3214",
tooltip = "$3234",
default = 1,
visible = 1,
choices =
{ "$3215", "Small", "$3216", "Normal", "$3217", "Large", }, },
{
name = "resstart",
locName = "$3205",
tooltip = "$3232",
default = 0,
visible = 1,
choices =
{ "$3206", "1000", "$3207", "3000", "$3208", "10000", "$3209", "0", }, },
{
name = "lockteams",
locName = "$3220",
tooltip = "$3235",
default = 0,
visible = 1,
choices =
{ "$3221", "yes", "$3222", "no", }, },
{
name = "startlocation",
locName = "$3225",
tooltip = "$3237",
default = 0,
visible = 1,
choices =
{ "$3226", "random", "$3227", "fixed", }, },
}
dofilepath("data:scripts/scar/restrict.lua")
Events = {}
Events.endGame =
{
{
{ "wID = Wait_Start(5)", "Wait_End(wID)", },
},
}
function OnInit()
MPRestrict()
Rule_Add("MainRule")
Rule_AddInterval("GravwellRule",1)
end
--updates the "AllShips" sobgroup to cover all the ships in the current universe
function Update_AllShips()
local playerIndex = 0
local playerCount = Universe_PlayerCount()
SobGroup_Create("AllShips")
SobGroup_Clear("AllShips")
while playerIndex<playerCount do
SobGroup_SobGroupAdd("AllShips","Player_Ships"..playerIndex)
playerIndex = playerIndex + 1
end
end
function SobGroup_SplitGroupReference(SobGroupOut, SobGroupToSplit, ReferenceSobGroup, NumberToSplit)
-- function created by Apollyon470
local index = 0
local distance = 0
local bool = 0
local SobNum = 0
SobGroup_Create("TempSobGroup")
SobGroup_Clear ("TempSobGroup")
SobGroup_Create("TempSobGroup1")
SobGroup_Clear ("TempSobGroup1")
SobGroup_SobGroupAdd ("TempSobGroup", SobGroupToSplit)
if ( SobGroup_Empty (SobGroupToSplit) == 1 ) then
return 0
end
if ( NumberToSplit > SobGroup_Count(SobGroupToSplit) ) then
NumberToSplit = SobGroup_Count(SobGroupToSplit)
end
while (index < NumberToSplit ) do
bool = 0
-- in the interests of resource saving, we start with a search band of 625
interval = 625
while (bool == 0) do
distance = distance + interval
-- something went wrong. Please tell me, or have a go at fixing it yourself.
if (interval > 3000000) then
bool =1
return SobNum
end
SobGroup_FillProximitySobGroup ("TempSobGroup1", "TempSobGroup", ReferenceSobGroup, distance)
if (SobGroup_Empty("TempSobGroup1") == 1)then
-- get the next interval
else
if (SobGroup_Count("TempSobGroup1") > 1) then
-- too many ships, reduce interval
if (interval <= .2) then
-- Screw it! chunk 'em all in the same sobgroup
SobGroup_Create(SobGroupOut .. tostring(SobNum))
SobGroup_Clear (SobGroupOut .. tostring(SobNum))
SobGroup_SobGroupAdd (SobGroupOut .. tostring(SobNum), "TempSobGroup1")
SobGroup_Create("tempsob")
SobGroup_FillSubstract("tempsob", "TempSobGroup", SobGroupOut .. tostring(SobNum))
SobGroup_Clear ("TempSobGroup")
SobGroup_SobGroupAdd ("TempSobGroup", "tempsob")
bool = 1
else
distance = distance - interval
interval = interval / 5
end
else
-- we got one! add it to the list!
SobGroup_Create(SobGroupOut .. tostring(SobNum))
SobGroup_Clear (SobGroupOut .. tostring(SobNum))
SobGroup_SobGroupAdd (SobGroupOut .. tostring(SobNum), "TempSobGroup1")
SobGroup_Create("tempsob")
SobGroup_FillSubstract("tempsob", "TempSobGroup", SobGroupOut .. tostring(SobNum))
SobGroup_Clear ("TempSobGroup")
SobGroup_SobGroupAdd ("TempSobGroup", "tempsob")
bool = 1
end
end
end
index = index + SobGroup_Count(SobGroupOut .. tostring(SobNum))
SobNum = SobNum + 1
end
return SobNum
end
function GravwellRule()
Update_AllShips()
--enable the move command for all ships
SobGroup_SetMaxSpeedMultiplier("AllShips", 1)
SobGroup_Create("GravwellsSob")
SobGroup_Create("TargetSob")
SobGroup_Create("TempSob")
SobGroup_Clear("TempSob")
--get our gravwells
SobGroup_FillShipsByType("GravwellsSob", "AllShips", "Hgn_Carrier")
--get our ships to potentially disable
SobGroup_FillShipsByType("TempSob", "AllShips", "Hgn_Scout")
SobGroup_SobGroupAdd("TargetSob","TempSob")
SobGroup_FillShipsByType("TempSob", "AllShips", "Hgn_Interceptor")
SobGroup_SobGroupAdd("TargetSob","TempSob")
SobGroup_FillShipsByType("TempSob", "AllShips", "Hgn_AssaultCorvette")
SobGroup_SobGroupAdd("TargetSob","TempSob")
SobGroup_FillShipsByType("TempSob", "AllShips", "Hgn_AttackBomber")
SobGroup_SobGroupAdd("TargetSob","TempSob")
SobGroup_FillShipsByType("TempSob", "AllShips", "Hgn_PulsarCorvette")
SobGroup_SobGroupAdd("TargetSob","TempSob")
--separate the gravwells
local Num = SobGroup_SplitGroupReference("Gravwell","GravwellsSob", "AllShips", SobGroup_Count("GravwellsSob"))
local i=0
SobGroup_Create("LocalTargetSob")
while (i<Num) do --for each gravwell
SobGroup_Clear("LocalTargetSob")
--get the nearby targets
SobGroup_FillProximitySobGroup("LocalTargetSob", "TargetSob","Gravwell"..i, 2000)
if (SobGroup_IsDoingAbility("Gravwell"..i, AB_DefenseField)==1)then
--disable them
SobGroup_SetMaxSpeedMultiplier("LocalTargetSob", 0)
end
i=i+1
end
end
function MainRule()
local playerIndex = 0
local playerCount = Universe_PlayerCount()
while playerIndex<playerCount do
if Player_IsAlive(playerIndex)==1 then
if Player_HasShipWithBuildQueue(playerIndex)==0 then
Player_Kill(playerIndex)
end
end
playerIndex = (playerIndex + 1)
end
local numAlive = 0
local numEnemies = 0
local gameOver = 1
playerIndex = 0
while playerIndex<playerCount do
if Player_IsAlive(playerIndex)==1 then
local otherPlayerIndex = 0
while otherPlayerIndex<playerCount do
if AreAllied(playerIndex, otherPlayerIndex)==0 then
if Player_IsAlive(otherPlayerIndex)==1 then
gameOver = 0
else
numEnemies = (numEnemies + 1)
end
end
otherPlayerIndex = (otherPlayerIndex + 1)
end
numAlive = (numAlive + 1)
end
playerIndex = (playerIndex + 1)
end
if numEnemies==0 and numAlive>0 then
gameOver = 0
end
if gameOver==1 then
Rule_Add("waitForEnd")
Event_Start("endGame")
Rule_Remove("MainRule")
end
end
function waitForEnd()
if Event_IsDone("endGame") then
setGameOver()
Rule_Remove("waitForEnd")
end
end