1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Method to test valid ranged target without unit?

Discussion in 'Civ5 - SDK / LUA' started by Pazyryk, Jun 22, 2014.

  1. Pazyryk

    Pazyryk Deity

    Joined:
    Jun 13, 2008
    Messages:
    3,584
    Hard to condense sensible question in thread title.

    Basically, I want to test whether one plot is a potential ranged target for another plot, assuming a ranged unit without indirect fire. The complication is I want to do this before placing the ranged unit, so I can't do the test on a unit object.

    Does anyone know if there is a reasonable way to do this? The code will run in Lua, although I can mod dll to expose new Lua method if it helps.
     
  2. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,518
    Location:
    Near Portsmouth, UK
    The code to determine if a unit can range strike at another plot, after removing all the checks for being a ranged unit, there being a target unit in the target plot, being at war with the target unit, etc, etc, boils down to

    Code:
    pFromPlot:CanSeePlot(pToPlot, iMyTeam, iMaxRange, -1)
    
     
  3. Pazyryk

    Pazyryk Deity

    Joined:
    Jun 13, 2008
    Messages:
    3,584
    Thanks! I missed that one for some reason...
     
  4. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,518
    Location:
    Near Portsmouth, UK
    ... and that reason is the Firaxis Spaghetti Code Monster :eek:

     

Share This Page