Initial commit

This commit is contained in:
2026-02-28 14:00:45 -06:00
commit 16d3170787
1134 changed files with 589134 additions and 0 deletions

View File

@@ -0,0 +1,316 @@
-- $Id: //depot/Projects/StarWars_Steam/FOC/Run/Data/Scripts/FreeStore/BusyTacticalFreeStore.lua#1 $
--/////////////////////////////////////////////////////////////////////////////////////////////////
--
-- (C) Petroglyph Games, Inc.
--
--
-- ***** ** * *
-- * ** * * *
-- * * * * *
-- * * * * * * * *
-- * * *** ****** * ** **** *** * * * ***** * ***
-- * ** * * * ** * ** ** * * * * ** ** ** *
-- *** ***** * * * * * * * * ** * * * *
-- * * * * * * * * * * * * * * *
-- * * * * * * * * * * ** * * * *
-- * ** * * ** * ** * * ** * * * *
-- ** **** ** * **** ***** * ** *** * *
-- * * *
-- * * *
-- * * *
-- * * * *
-- **** * *
--
--/////////////////////////////////////////////////////////////////////////////////////////////////
-- C O N F I D E N T I A L S O U R C E C O D E -- D O N O T D I S T R I B U T E
--/////////////////////////////////////////////////////////////////////////////////////////////////
--
-- $File: //depot/Projects/StarWars_Steam/FOC/Run/Data/Scripts/FreeStore/BusyTacticalFreeStore.lua $
--
-- Original Author: Steve_Copeland
--
-- $Author: Brian_Hayes $
--
-- $Change: 637819 $
--
-- $DateTime: 2017/03/22 10:16:16 $
--
-- $Revision: #1 $
--
--/////////////////////////////////////////////////////////////////////////////////////////////////
require("pgcommands")
function Base_Definitions()
Common_Base_Definitions()
ServiceRate = 20
UnitServiceRate = 2
if Definitions then
Definitions()
end
FREE_STORE_ATTACK_RANGE = 600.0
end
function main()
if FreeStoreService then
while 1 do
FreeStoreService()
PumpEvents()
end
end
ScriptExit()
end
function On_Unit_Added(object)
end
function FreeStoreService()
enemy_location = FindTarget.Reachable_Target(PlayerObject, "Current_Enemy_Location", "Tactical_Location", "Any_Threat", 0.5)
friendly_location = FindTarget.Reachable_Target(PlayerObject, "Current_Friendly_Location", "Tactical_Location", "Any_Threat", 0.5)
aggressive_mode = (EvaluatePerception("Allowed_As_Defender_Land", PlayerObject) > 0.0)
--Manage the space station in space mode
if Get_Game_Mode() == "Space" then
if TestValid(space_station) then
station_threat = FindDeadlyEnemy(space_station)
if station_threat then
space_station.Attack_Target(station_threat)
end
--Maybe this station has a special weapon?
special_target = FindTarget.Reachable_Target(PlayerObject, "Needs_Hypervelocity_Shot", "Enemy_Unit", "Any_Threat", 0.5, space_station, 1500.0)
if TestValid(special_target) then
space_station.Fire_Special_Weapon(special_target, PlayerObject)
end
else
space_station = PlayerObject.Get_Space_Station()
end
end
end
function On_Unit_Service(object)
if not TestValid(object) then
return
end
if object.Is_Category("Structure") or object.Is_Category("Transport") then
return
end
current_target = object.Get_Attack_Target()
if TestValid(current_target) then
if Service_Heal(object, 0.6) then
return
end
if Service_Kite(object) then
return
end
object.Activate_Ability("SPOILER_LOCK", false)
Try_Weapon_Switch(object, current_target)
end
if not object.Has_Active_Orders() then
--Keep bored objects mobile
object.Activate_Ability("SPOILER_LOCK", true)
if Service_Kite(object) then
return
end
if Service_Heal(object, 1.0) then
return
end
-- Reset some abilities
object.Activate_Ability("SPREAD_OUT", false)
if Service_Garrison(object) then
return
end
if Service_Attack(object) then
return
end
Service_Guard(object)
end
end
function Service_Heal(object, health_threshold)
--Add difficulty factor here
if object.Get_Hull() < health_threshold then
-- Try to find the nearest healing structure appropriate for this unit
lib_fs_healer_property_flag = Get_Special_Healer_Property_Flag(object)
if not lib_fs_healer_property_flag then
if object.Is_Category("Infantry") then
lib_fs_healer_property_flag = "HealsInfantry"
elseif object.Is_Category("Vehicle") then
lib_fs_healer_property_flag = "HealsVehicles"
end
end
if lib_fs_healer_property_flag then
healer = Find_Nearest(object, lib_fs_healer_property_flag, PlayerObject, true)
end
if TestValid(healer) then
if object.Get_Distance(healer) > 100.0 then
object.Activate_Ability("SPREAD_OUT", false)
Try_Ability(object,"Turbo")
Try_Ability(object,"JET_PACK", healer)
Try_Ability(object,"SPRINT")
Try_Ability(object, "SPOILER_LOCK")
Try_Ability(object, "STEALTH")
Try_Ability(object, "FORCE_CLOAK")
object.Move_To(healer, 10)
return true
end
end
end
return false
end
function Service_Garrison(object)
if object.Has_Property("CanContainGarrison") then
lib_garrison_table = object.Get_Garrisoned_Units()
if table.getn(lib_garrison_table) > 0 then
lib_garrison_needs_heals = true
lib_garrison_healer = Find_Nearest(object, "HealsInfantry", object.Get_Owner(), true)
lib_garrison_enemy = Find_Nearest(object, object.Get_Owner(), false)
lib_eject_for_heal = TestValid(lib_garrison_healer) and (object.Get_Distance(lib_garrison_healer) < 150)
lib_eject_for_attack = (not object.Has_Property("GarrisonCanFire")) and TestValid(lib_garrison_enemy) and (object.Get_Distance(lib_garrison_enemy) < FREE_STORE_ATTACK_RANGE)
for i,garrison in pairs(lib_garrison_table) do
if garrison.Get_Hull() > 0.4 then
lib_garrison_needs_heals = false
if lib_eject_for_attack and garrison.Is_Good_Against(lib_garrison_enemy) then
garrison.Leave_Garrison()
end
elseif lib_eject_for_heal then
garrison.Leave_Garrison()
end
end
if lib_garrison_needs_heals and TestValid(lib_garrison_healer) then
object.Move_To(lib_garrison_healer)
return true
end
end
end
return false
end
function Service_Attack(object)
--Move to the enemy position rather than the enemy itself in order to leave us free
--to run autonomous targeting. While this doesn't provide chase behavior we're probably
--repeating this enough that we don't care
closest_enemy = Find_Nearest(object, object.Get_Owner(), false)
if TestValid(closest_enemy) and not closest_enemy.Is_Good_Against(object) then
if object.Get_Distance(closest_enemy) < FREE_STORE_ATTACK_RANGE then
object.Attack_Move(closest_enemy.Get_Position())
return true
elseif aggressive_mode then
if not Try_Garrison(nil, object, false, FREE_STORE_ATTACK_RANGE / 2.0) then
object.Attack_Move(closest_enemy.Get_Position())
end
return true
end
elseif TestValid(enemy_location) then
if aggressive_mode then
object.Attack_Move(enemy_location)
return true
end
end
return false
end
function Service_Guard(object)
if Try_Deploy_Garrison(object, nil, 0.0) then
return true
end
closest_friendly_structure = Find_Nearest(object, "Structure", object.Get_Owner(), true)
if TestValid(closest_friendly_structure) then
object.Guard_Target(closest_friendly_structure)
return true
elseif TestValid(friendly_location) then
object.Attack_Move(friendly_location)
return true
end
return false
end
function Service_Kite(object)
lib_fs_deadly_enemy = FindDeadlyEnemy(object)
if TestValid(lib_fs_deadly_enemy) then
if lib_fs_deadly_enemy.Is_Good_Against(object) then
if Try_Ability(object, "PROXIMITY_MINES", object) then
return true
end
if Try_Ability(object, "BUZZ_DROIDS", object) then
return true
end
object.Activate_Ability("SPREAD_OUT", false)
Try_Ability(object, "TURBO")
Try_Ability(object, "SPRINT")
Try_Ability(object, "SPOILER_LOCK")
Try_Ability(object, "STEALTH")
Try_Ability(object, "FORCE_CLOAK")
if object.Get_Hull() > 0.5 then
Try_Ability(object, "STIM_PACK")
end
lib_fs_kite_pos = Project_By_Unit_Range(lib_fs_deadly_enemy, object)
if Try_Ability(object, "JET_PACK", lib_fs_kite_pos) then
return true
end
object.Move_To(lib_fs_kite_pos)
return true
end
end
return false
end

View File

@@ -0,0 +1,313 @@
--/////////////////////////////////////////////////////////////////////////////////////////////////
-- (c) Galyana's Ultimate Empire at War Modifications
--
-- ****** *** *** ************ *** ***
-- * * * * * * * *
-- * * * * * * *
-- * * * * * * *
-- * * * * * **** * * *
-- * * * ****** * * * *
-- * **** * * * * * * * *** *
-- * * * * * * * * * *
-- * * * * * * * * * *
-- * * * * * * * ** * * *
-- ****** ****** ************ **** ** *******
--/////////////////////////////////////////////////////////////////////////////////////////////////
-- C O N F I D E N T I A L S O U R C E C O D E -- D O N O T D I S T R I B U T E
--/////////////////////////////////////////////////////////////////////////////////////////////////
--
-- File: GUEaW/Data/Scripts/FreeStore/GalacticFreeStore.LUA
--
-- Original Editor: Giovanni Galyana
--
-- Final Edit By: Giovanni Galyana
--
-- Date: 7 March, 2019
--
-- Revisions: 0
--
--/////////////////////////////////////////////////////////////////////////////////////////////////
require("pgcommands")
require("GalacticHeroFreeStore")
function Base_Definitions()
DebugMessage("%s -- In Base_Definitions", tostring(Script))
-- how often does this script get serviced?
ServiceRate = 8
UnitServiceRate = 8
Common_Base_Definitions()
-- Percentage of units to move on each service.
SpaceMovePercent = 0.10
GroundMovePercent = 0.10
if Definitions then
Definitions()
end
end
function main()
DebugMessage("%s -- In main for %s", tostring(Script), tostring(FreeStore))
if FreeStoreService then
while 1 do
FreeStoreService()
PumpEvents()
end
end
ScriptExit()
end
function MoveUnit(object)
dest_target = nil
object_type = object.Get_Type()
if object_type.Is_Hero() then
dest_target = Find_Custom_Target(object)
end
if not TestValid(dest_target) then
if object.Is_Transport() then
dest_target = Find_Ground_Unit_Target(object)
else
dest_target = Find_Space_Unit_Target(object)
end
end
if dest_target then
FreeStore.Move_Object(object, dest_target)
return true
else
DebugMessage("%s -- Object: %s, unable to find a suitable destination for this object.", tostring(Script), tostring(object))
return false
end
end
function On_Unit_Service(object)
-- If this unit isn't in a safe spot move him regardless of the MovedUnitsThisService
-- Also, Heroes need to be where they most want to be asap
if (FreeStore.Is_Unit_Safe(object) == false) or (object.Get_Type().Is_Hero()) then
MoveUnit(object)
return
end
if object.Is_Transport() then
if GameRandom.Get_Float() < GroundAvailablePercent and GroundUnitsMoved < GroundUnitsToMove then
if FreeStore.Is_Unit_In_Transit(object) == false then
DebugMessage("%s -- Object: %s service move order issued", tostring(Script), tostring(object))
if MoveUnit(object) then
GroundUnitsMoved = GroundUnitsMoved + 1
end
end
end
else
if GameRandom.Get_Float() < SpaceAvailablePercent and SpaceUnitsMoved < SpaceUnitsToMove then
if FreeStore.Is_Unit_In_Transit(object) == false then
DebugMessage("%s -- Object: %s service move order issued", tostring(Script), tostring(object))
if MoveUnit(object) then
SpaceUnitsMoved = SpaceUnitsMoved + 1
end
end
end
end
end
-- // param 1: playerwrapper.
-- // param 2: perception function name
-- // param 3: goal application type string
-- // param 4: reachability type string
-- // param 5: The probability of selecting the target with highest desire
-- // param 6: The source from which the find target should search for relative targets.
-- // param 7: The maximum distance from source to target.
function On_Unit_Added(object)
DebugMessage("%s -- Object: %s added to freestore", tostring(Script), tostring(object))
obj_type = object.Get_Type()
if obj_type.Is_Hero() then
DebugMessage("%s -- Hero Object: %s added to freestore", tostring(Script), obj_type.Get_Name())
end
MoveUnit(object)
end
function FreeStoreService()
if PlayerObject.Get_Faction_Name() == "REBEL" then
leader_object = Find_First_Object("MON_MOTHMA")
elseif PlayerObject.Get_Faction_Name() == "EMPIRE" then
leader_object = Find_First_Object("EMPEROR_PALPATINE")
end
MovedUnitsThisService = 0
GroundUnitsMoved = 0
GroundUnitsToMove = 0
SpaceUnitsMoved = 0
SpaceUnitsToMove = 0
SpaceAvailablePercent = 0
GroundAvailablePercent = 0
object_count = FreeStore.Get_Object_Count()
if object_count ~= 0 then
-- get the count of space force in the freestore
scnt = FreeStore.Get_Object_Count(true)
-- get the count of ground force in the freestore
gcnt = FreeStore.Get_Object_Count(false)
SpaceAvailablePercent = scnt / object_count
GroundAvailablePercent = gcnt / object_count
SpaceUnitsToMove = SpaceMovePercent * scnt
GroundUnitsToMove = GroundMovePercent * gcnt
DebugMessage("%s -- SpaceAvailablePercent: %f, GroundAvailablePercent: %f, SpaceUnitsToMove: %f, GroundUnitsToMove: %f, scnt: %f, gcnt: %f",
tostring(Script), SpaceAvailablePercent, GroundAvailablePercent, SpaceUnitsToMove, GroundUnitsToMove, scnt, gcnt)
end
end
function Find_Ground_Unit_Target(object)
my_planet = object.Get_Planet_Location()
if FreeStore.Is_Unit_Safe(object) == false then
my_planet = nil
end
if leader_object then
leader_planet = leader_object.Get_Planet_Location()
end
max_force_target = 1000 * (PlayerObject.Get_Tech_Level() + 1)
force_target = EvaluatePerception("Friendly_Global_Land_Unit_Raw_Total", PlayerObject)
if not force_target then
return nil
end
force_target = force_target / 4.0
if force_target > max_force_target then
force_target = max_force_target
end
if leader_planet then
if leader_planet == my_planet then
return nil
elseif leader_planet.Get_Is_Planet_AI_Usable() and object.Can_Land_On_Planet(leader_planet) then
if EvaluatePerception("Friendly_Land_Unit_Raw_Total", PlayerObject, leader_planet) < force_target then
return leader_planet
end
end
end
priority_planet = FindTarget.Reachable_Target(PlayerObject, "Ground_Priority_Defense_Score", "Friendly", "Friendly_Only", 0.1, object)
if priority_planet then
priority_planet = priority_planet.Get_Game_Object()
end
if priority_planet then
if priority_planet == my_planet then
return nil
elseif priority_planet.Get_Is_Planet_AI_Usable() and object.Can_Land_On_Planet(priority_planet) then
if EvaluatePerception("Friendly_Land_Unit_Raw_Total", PlayerObject, priority_planet) < force_target then
return priority_planet
end
end
end
if my_planet and EvaluatePerception("Low_Ground_Defense_Score", PlayerObject, my_planet) > 0.5 then
return nil
end
poorly_defended_planet = FindTarget.Reachable_Target(PlayerObject, "Low_Ground_Defense_Score", "Friendly", "Friendly_Only", 1.0, object)
if poorly_defended_planet then
poorly_defended_planet = poorly_defended_planet.Get_Game_Object()
end
if poorly_defended_planet and poorly_defended_planet.Get_Is_Planet_AI_Usable() and object.Can_Land_On_Planet(poorly_defended_planet) then
return poorly_defended_planet
end
if not my_planet then
fallback_planet = FindTarget.Reachable_Target(PlayerObject, "One", "Friendly", "Friendly_Only", 0.1, object)
if fallback_planet then
return fallback_planet.Get_Game_Object()
end
end
return nil
end
function Find_Space_Unit_Target(object)
my_planet = object.Get_Planet_Location()
if not my_planet then
return nil
end
if leader_object then
leader_planet = leader_object.Get_Planet_Location()
end
max_force_target = 3000 * (PlayerObject.Get_Tech_Level() + 1)
force_target = EvaluatePerception("Friendly_Global_Space_Unit_Raw_Total", PlayerObject)
if not force_target then
return nil
end
force_target = force_target / 4.0
if force_target > max_force_target then
force_target = max_force_target
end
if leader_planet and leader_planet.Get_Is_Planet_AI_Usable() then
if leader_planet == my_planet then
if EvaluatePerception("Friendly_Space_Unit_Raw_Total", PlayerObject, leader_planet) < 1.5 * force_target then
return leader_planet
end
elseif EvaluatePerception("Friendly_Space_Unit_Raw_Total", PlayerObject, leader_planet) < force_target then
if EvaluatePerception("Enemy_Present", PlayerObject, leader_planet) == 0.0 then
return leader_planet
end
end
end
priority_planet = FindTarget.Reachable_Target(PlayerObject, "Space_Priority_Defense_Score", "Friendly", "Friendly_Only", 0.1, object)
if priority_planet then
priority_planet = priority_planet.Get_Game_Object()
end
if priority_planet and priority_planet.Get_Is_Planet_AI_Usable() then
if priority_planet == my_planet then
if EvaluatePerception("Friendly_Space_Unit_Raw_Total", PlayerObject, priority_planet) < 1.5 * force_target then
return priority_planet
end
elseif EvaluatePerception("Friendly_Space_Unit_Raw_Total", PlayerObject, priority_planet) < force_target then
if EvaluatePerception("Enemy_Present", PlayerObject, priority_planet) == 0.0 then
return priority_planet
end
end
end
if my_planet and EvaluatePerception("Low_Space_Defense_Score", PlayerObject, my_planet) > 0.5 then
return nil
end
poorly_defended_planet = FindTarget.Reachable_Target(PlayerObject, "Low_Space_Defense_Score", "Friendly", "Friendly_Only", 1.0, object)
if poorly_defended_planet then
poorly_defended_planet = poorly_defended_planet.Get_Game_Object()
end
if poorly_defended_planet and poorly_defended_planet.Get_Is_Planet_AI_Usable() then
if EvaluatePerception("Friendly_Space_Unit_Raw_Total", PlayerObject, poorly_defended_planet) < force_target then
if EvaluatePerception("Enemy_Present", PlayerObject, poorly_defended_planet) == 0.0 then
return poorly_defended_planet
end
end
end
return nil
end

View File

@@ -0,0 +1,105 @@
--/////////////////////////////////////////////////////////////////////////////////////////////////
-- (c) Galyana's Ultimate Empire at War Modifications
--
-- ****** *** *** ************ *** ***
-- * * * * * * * *
-- * * * * * * *
-- * * * * * * *
-- * * * * * **** * * *
-- * * * ****** * * * *
-- * **** * * * * * * * *** *
-- * * * * * * * * * *
-- * * * * * * * * * *
-- * * * * * * * ** * * *
-- ****** ****** ************ **** ** *******
--/////////////////////////////////////////////////////////////////////////////////////////////////
-- C O N F I D E N T I A L S O U R C E C O D E -- D O N O T D I S T R I B U T E
--/////////////////////////////////////////////////////////////////////////////////////////////////
--
-- File: GUEaW/Data/Scripts/FreeStore/GalacticHeroFreeStore.LUA
--
-- Original Editor: Giovanni Galyana
--
-- Final Edit By: Giovanni Galyana
--
-- Date: 7 March, 2019
--
-- Revisions: 0
--
--/////////////////////////////////////////////////////////////////////////////////////////////////
require("pgcommands")
function Definitions()
DebugMessage("%s -- Defining custom freestore movement perceptions", tostring(Script))
-- Table which maps heroes to perceptions for systems they like to hang out on when not in active use
-- The boolean is for whether or not the hero prefers to stay in space, if he has a choice
-- Generally, this is to find the system where their abilities provide the best defensive or infrastructure bonuses
CustomUnitPlacement = {
EMPEROR_PALPATINE_TEAM = {"Is_Home_Planet", false}
,GRAND_MOFF_TARKIN_TEAM = {"Is_Home_Planet", true}
,UEAW_SATE_PESTAGE_TEAM = {"Is_Home_Planet", false}
,DARTH_TEAM = {nil, false}
,DARTH_TEAM_EXECUTOR = {nil, true}
,GENERAL_VEERS_TEAM = {nil, false}
,BOBA_FETT_TEAM = {nil, true}
,ACCUSER_STAR_DESTROYER = {nil, true}
,ADMIRAL_PIETT_EXECUTOR = {nil, true}
,ISD_GORGON = {nil, true}
,PELLAEON_ACCLAMATOR = {nil, true}
,ARC_HAMMER = {"Is_Home_Planet", true}
,ADMONITOR_STAR_DESTROYER = {nil, true}
,MON_MOTHMA_TEAM = {"Is_Home_Planet", false}
,HOME_ONE = {nil, true}
,HAN_SOLO_TEAM = {nil, false}
,OBI_WAN_TEAM = {nil, false}
,DROIDS_TEAM = {nil, false}
,LUKE_TEAM = {nil, true}
,LUKE_SKYWALKER_JEDI_TEAM = {nil, false}
,YODA_TEAM = {nil,false}
,ROGUE_SQUADRON_SPACE = {nil,true}
,BOSSK_TEAM = {nil, true}
,IG88_TEAM = {nil, true}
,SILRI_TEAM = {nil, false}
,URAI_FEN_TEAM = {nil, false}
,TYBER_ZANN_TEAM = {nil, true}
,ERRANT_VENTURE = {nil, true}
,NIKOMER_TEAM = {nil, true}
,CUARSON_TEAM = {nil, true}
,SYKARIIUS_TEAM = {nil, true}
,XIZOR_TEAM = {nil, false}
,PESTELOUS_TEAM = {nil, true}
,GALYANA_SSD_GC = {nil, true}
}
end
function Find_Custom_Target(object)
object_type = object.Get_Type()
object_type_name = object_type.Get_Name()
unit_entry = CustomUnitPlacement[object_type_name]
if unit_entry then
perception = unit_entry[1]
prefers_space = unit_entry[2]
if perception then
target = FindTarget.Reachable_Target(PlayerObject, perception, "Friendly", "No_Threat", 1.0, object)
if TestValid(target) then
return target
end
end
if prefers_space then
return Find_Space_Unit_Target(object)
else
return Find_Ground_Unit_Target(object)
end
else
DebugMessage("%s -- Error: Type %s not found in CustomUnitPlacement table.", tostring(Script), object_type_name)
end
end

View File

@@ -0,0 +1,79 @@
-- $Id: //depot/Projects/StarWars_Steam/FOC/Run/Data/Scripts/FreeStore/GenericFreeStore.lua#1 $
--/////////////////////////////////////////////////////////////////////////////////////////////////
--
-- (C) Petroglyph Games, Inc.
--
--
-- ***** ** * *
-- * ** * * *
-- * * * * *
-- * * * * * * * *
-- * * *** ****** * ** **** *** * * * ***** * ***
-- * ** * * * ** * ** ** * * * * ** ** ** *
-- *** ***** * * * * * * * * ** * * * *
-- * * * * * * * * * * * * * * *
-- * * * * * * * * * * ** * * * *
-- * ** * * ** * ** * * ** * * * *
-- ** **** ** * **** ***** * ** *** * *
-- * * *
-- * * *
-- * * *
-- * * * *
-- **** * *
--
--/////////////////////////////////////////////////////////////////////////////////////////////////
-- C O N F I D E N T I A L S O U R C E C O D E -- D O N O T D I S T R I B U T E
--/////////////////////////////////////////////////////////////////////////////////////////////////
--
-- $File: //depot/Projects/StarWars_Steam/FOC/Run/Data/Scripts/FreeStore/GenericFreeStore.lua $
--
-- Original Author: Brian Hayes
--
-- $Author: Brian_Hayes $
--
-- $Change: 637819 $
--
-- $DateTime: 2017/03/22 10:16:16 $
--
-- $Revision: #1 $
--
--/////////////////////////////////////////////////////////////////////////////////////////////////
require("pgcommands")
function Base_Definitions()
DebugMessage("%s -- In Base_Definitions", tostring(Script))
Common_Base_Definitions()
ServiceRate = 10
UnitServiceRate = 10
if Definitions then
Definitions()
end
end
function main()
DebugMessage("%s -- In main for %s", tostring(Script), tostring(FreeStore))
if FreeStoreService then
while 1 do
FreeStoreService()
PumpEvents()
end
end
ScriptExit()
end
function On_Unit_Added(object)
DebugMessage("%s -- Object: %s added to freestore", tostring(Script), tostring(object))
end
function FreeStoreService()
end

View File

@@ -0,0 +1,130 @@
-- $Id: //depot/Projects/StarWars/Run/Data/Scripts/FreeStore/HumanGalacticFreeStore.lua#2 $
--/////////////////////////////////////////////////////////////////////////////////////////////////
--
-- (C) Petroglyph Games, Inc.
--
--
-- ***** ** * *
-- * ** * * *
-- * * * * *
-- * * * * * * * *
-- * * *** ****** * ** **** *** * * * ***** * ***
-- * ** * * * ** * ** ** * * * * ** ** ** *
-- *** ***** * * * * * * * * ** * * * *
-- * * * * * * * * * * * * * * *
-- * * * * * * * * * * ** * * * *
-- * ** * * ** * ** * * ** * * * *
-- ** **** ** * **** ***** * ** *** * *
-- * * *
-- * * *
-- * * *
-- * * * *
-- **** * *
--
--/////////////////////////////////////////////////////////////////////////////////////////////////
-- C O N F I D E N T I A L S O U R C E C O D E -- D O N O T D I S T R I B U T E
--/////////////////////////////////////////////////////////////////////////////////////////////////
--
-- $File: //depot/Projects/StarWars/Run/Data/Scripts/FreeStore/HumanGalacticFreeStore.lua $
--
-- Original Author: James Yarrow
--
-- $Author: Brian_Hayes $
--
-- $Change: 20677 $
--
-- $DateTime: 2005/06/24 17:01:12 $
--
-- $Revision: #2 $
--
--/////////////////////////////////////////////////////////////////////////////////////////////////
require("pgcommands")
require("FleetEvents")
function Base_Definitions()
ServiceRate = 1
Common_Base_Definitions()
if Definitions then
Definitions()
end
FleetType = nil
fleet_table = {}
fleet_key = nil
fleet = nil
increment = 0.001
roll = nil
threshold = 0.0
event = nil
parent = nil
Init_Fleet_Events()
end
function main()
FleetType = Find_Object_Type("Galactic_Fleet")
if FreeStoreService then
while 1 do
FreeStoreService()
PumpEvents()
end
end
ScriptExit()
end
function On_Unit_Service(object)
parent = object.Get_Parent_Object()
if parent and parent.Get_Type() == FleetType then
fleet_table[parent] = parent
end
end
function FreeStoreService()
for fleet_key, fleet in pairs(fleet_table) do
if TestValid(fleet) then
Evaluate_Random_Event(fleet)
else
fleet_table[fleet_key] = nil
end
Sleep(0.5)
end
end
function Evaluate_Random_Event(fleet)
event = FleetEventTable.Sample()
if not event.Is_Appropriate_For_Fleet(fleet) then
return
end
--roll to determine whether an event takes place. The chance of an event
--increases with the amount of time that's passed with no event.
roll = GameRandom.Get_Float()
if roll > threshold then
threshold = increment + threshold
return
end
threshold = 0.0
if GameRandom.Get_Float() > event.Get_Avoidance_Chance(fleet) then
--Execute event
event.Execute(fleet)
else
--Inform user that event was avoided
event.Avoided(fleet)
end
end
function On_Unit_Added(object)
end