Selections

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
Post Reply
Lachu
Elite
Posts: 472
Joined: Sat May 04, 2013 2:19 pm

Selections

Post by Lachu »

I known, Freeciv team probably working on select UI for actions, but this is not only for actions and I describe my idea.

Format will be just like that:

Code: Select all


[selection_goto_1]
name = "goto_order_dsc1"
type = "tile"
// Below my imagination of req type
reqs = {
   "Name", "Value", "Range"
   "Occupied", 0, "Other"
}

function =
{
   "Name", "Range", "Function"
   "Move_Cost", "Tile", "None"
   "MP", "Unit", "Greater"
}

[selection_goto_2]
name = "goto_order_dsc2"
type = "tile"
// Below my imagination of req type
reqs = {
   "Name", "Value", "Range"
   "Occupied", 1, "Ally"
}

function =
{
   "Name", "Range", "Function"
   "Move_Cost", "Tile", "None"
   "MP", "Unit", "Greater"
}

[selection_goto_3]
name = "goto_order_src"
type = "unit"

reqs = {
   "Name", "Value", "Range"
   
}

[action_move1]
name_gui = "move"
actor = {
   "Name", "Value", "Range"
   "SetSelection", "goto_order_src", "Player"
}

target = {

    "Name", "Value", "Range"
    "SetSelection", "goto_order_dsc1", "World"
}


[action_move2]
name_gui = "move"
actor = {
   "Name", "Value", "Range"
   "SetSelection", "goto_order_src", "Player"
}

target = {

    "Name", "Value", "Range"
    "SetSelection", "goto_order_dsc2", "World"
}
Another example:

Code: Select all


[action_fire_arrows]
name_gui = "ranged attack"
actor = {
    "Name", "Value", "Range"
    "UnitType", "Archers", "City"
    "Building", "Towers", "City"
    "Building", "City Walls", "City"
   "SetSelection", "From", "Unit"
}

target = {
    "Name", "Value", "Range"
    "SetSelection", "To", "Unit"

}

add_cond = {
      "Name", "Value", "Range"
      "MaxDistance", 1, "From/To"
}

[effect_attack_from_towers_add_fp]
name = "AttackBonus"
value = "10"
reqs = {

   "Action", "ranged attack", "Unit" 
}

Other example:

Code: Select all


[selection_commando_special_attack]
name = "target selection"
type = "Unit"
reqs = {
   "Name", "Value", "Range"
   "DiplRelation", "War", "Unit"
}


[action_attack_commando]
name_ui = "select target"
type = "begin battle"
actor_reqs = {
   "Name", "Value",  "Range"
   "UnitType", "Commando", "Player"
   "SetSelection", "From", "Unit"
}

target_reqs = {
    "Name", "Value",  "Range"
   "SetSelection", "To", "Unit"
   "SetSelection", "target selection", "Unit"
   // We do not attack civilian units
   "UnitClass", "Military", "Selection1",
}

add_cond = {
      "Name", "Value", "Range"
      "MaxDistance", 1, "From/To"
}

Explanation:

Firstly, we need to introduce new range - Selection1, Selection2, Selection3, ..., Selection9 (for example). Selection section will contains name, type, reqs and function. Type is type of selection (for example units, tile, city, player, etc.). It decides, what player or game is supposed to select. When calling selection from effect or action, we give from which set of selection kind give to selection. For example, selection is kind unit, and range of setselection is world. In fact, player can select any world unit. If range is player, player could only select self unit. Function are additional requirements, to be calculated. We can for example check if attack power of enemy and our units are greater of 20. If so, do world anihilation!

Code: Select all

[selection_1]
// Caller of action will won
name="world_anihilation" 
type="unit"

type = {
   "Name", "Value", "Range"
   "DiplRel", "War", "Other"
}

[effect_won]
type = "Victory"
value = "1"
reqs = {
   "Name", "Value", "Range"
    "SetSelection", "To", "Unit"
    "Action", "Mass Destruction", "Unit"
    "SetSelection", "world anihilation", "World"
}

function =
{
   "Name", "Range", "Function"
   "HP", "To", "None"
   "HP", "Selection1", "SUM"
   "Check", 20, "Greater"
}
There is two special selection, which player cannot define and it is used with special laws: To/From. There is also special Range: To/From, for example to check distance between To and From.

Function could be MAX, MIN, AVG to select one of items, which pass requirements.

Implementation:
For effects, there could be some problems. If player is suppose to select, because reqs and function are true for many units, we need to cache selection. Player may change selection in special gui. Problem is, we need garbage collector or some stuff, because city could be razed, unit can be killed, etc. That will be most annoying thing in implementation of this.

I could try to implement this, but I doubt I will do this, because my current project (counters) do not have attention of developers. So I am waiting for suggestions.
Post Reply