Find specific facility type on planet |
I'm adding some counter-intelligence options under the Intelligence attacks and all is well except for the last one. I'm trying to, in effect, have your intel agents destroy an intelligence center of the target empire. My methodology is to
1) randomly loop through enemy empire planets
2) randomly loop through facilities on that planet
3) if facility == intel then kill it
4) exit function
Steps 1 and 2 are fine but once I have the list of facility ids on a planet, I don't know how to determine which facilities are intel centers. Is there a sys function that returns type of facility if supplied with facility_id? Is there a function to destroy a facility by id? Is there a better way to do this? So far what I have is....
function Execute_Intel_Counter_Terminate returns boolean
params
src_plr: long
trg_plr: long
vars
colony_list: longlist
fac_ids: longlist
fac_levs: longlist
cur_col: long
num_cols: long
ret_val: long
ret_bool: boolean
num_facs: long
cur_fac: long
begin
// build list of all enemy colonies
set ret_val := Sys_Get_List_Of_Players_Colonies(trg_plr,colony_list)
// loop through colonies looking for intel
set num_cols := colony_list.count()
if (num_cols > 0) then
loop
// get facility info for current colony
set cur_col := Sys_Get_Random_Long(1, num_cols)
set ret_bool := Sys_Get_Space_Object_Cargo_List_Of_Facilities(cur_col,fac_ids,fac_levs)
// loop through facilities for this colony looking for intel
for cur_fac := 1 to fac_ids.count() do
// determine type of facility
// if it's intel kill it and exit out
exitwhen (TRUE)
endfor
call colony_list.delete(cur_col)
set num_cols := colony_list.count()
exitwhen (num_cols




Re: Find specific facility type on planet
Here is what I have so far:
cargo_ammount: long
cargo_index: long
this_cargo_id: long
this_facility_id: long
planet_id: long
building_destroyed: boolean
set cargo_ammount := Sys_Get_Space_Object_Cargo_Item_Count(planet_id)
set cargo_index := 0
loop
set cargo_index := cargo_index + 1
set this_cargo_id := Sys_Get_Space_Object_Cargo_Item_ID(planet_id, cargo_index)
if Sys_Get_Space_Object_Cargo_Item_Type(planet_id, this_cargo_id) = CARGO_ITEM_TYPE_FACILITY then
set this_facility_id := Sys_Get_Space_Object_Cargo_Item_Facility_ID(planet_id, this_cargo_id)
if (this_facility_id = Sys_Get_Best_Facility_With_Ability(target_player, "Point Generation - Intelligence")) then
// --- Destroy the cargo object.
set building_destroyed := TRUE
endif
endif
exitwhen (cargo_index >= cargo_ammount) or (building_destroyed)
endloop
Now for the problem:
I cannot find any way to delete or damage any singular cargo item. The closest I can get is Sys_Space_Object_Scrap_Cargo, but this returns resources to the owning player. I guess the sabotuers could deliver the resources as an apology...
Other than this, we can destroy all cargo on an object at once, or inflict damage to a planet. Either of those options are not discriminating enough to let you destroy a specific object.