Menu

#22 'Militia' Python. Civics Spawn Units From Improvements.

1.0
for-test
Lib Spit
None
2015-06-03
2015-02-03
Lib Spit
No

The Current version of this spawns a Unit on Construction of the Improvement, when that civic is activate.

It might be nice to have the second option of it also being able to spawn repeatedly.

I am not sure how the spawning rate works at the moment, but it would be good if that were definable too, so it could be very slow or very fast depending on how it is set each time. Rather than being one fixed rate spawning rate across the board.

Discussion

  • Archid

    Archid - 2015-02-03

    The current spawning mechanism is controlled by the Handicap and GameSpeed, but the improvement can apply a percentage modifier to this. The code is this:

    // Get the base spawn rate from the game handicap
    int iChance = GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getLairSpawnRate();
    iChance *= 10000;
    
    // Modify by the improvements spawn modifier (default = 100 so no change)
    iChance *= GC.getImprovementInfo(getImprovementType()).getSpawnRatePercentage();
    iChance /= 100;
    
    // Apply the GameSpeed unit training modifier so fast speeds = more spawns
    iChance /= GC.getGameSpeedInfo(GC.getGameINLINE().getGameSpeedType()).getTrainPercent();
    if (GC.getGameINLINE().getSorenRandNum(10000, "Spawn Unit") < iChance)
    

    If you don't want the improvement to keep spawning then you can set the <iSpawnRatePercentage> tag on the improvement to 0.

    I still need to add something that will spawn a unit when the improvement is built as that doesn't exist yet. The existing lairs do that in the map generation code.

     
  • Lib Spit

    Lib Spit - 2015-02-03

    That sounds good!

    I think the spawn on creation is important, so thank you for working on that.

    It will allow things like forts to spawn a static defence turret and stuff under certain conditions. which will be cool!

    With the improvement spawn rate, can it be both +/- percentage so it can be made slower and faster than the norm?

    That would be cool! :D

     
  • Archid

    Archid - 2015-02-03

    The rate is a percentage so 50 halves the spawn rate whilst 200 doubles it

    There is no 'under certain conditions' in this it will spawn a unit when it is built and/or randomly

     
  • Lib Spit

    Lib Spit - 2015-02-03

    So we couldn't for example have

    Civic A, make Improvement A, Spawn Unit A at 50% speed

    And

    Civic B, make Improvement A, Spawn Unit A at 150% speed

    And (when ported)

    Trait A, make Improvement A, Spawn Unit A at 100% speed

    My guess with this last one is that it would potential clash with Civic A or B and explode?

     
  • Lib Spit

    Lib Spit - 2015-02-03

    hmmm for some reason I cannot see the last comment you wrote, it only seems to be in my email.

    Anyway...

    That I dea for putting the rates/effects into improvements is fine by me. Do you think we could also have a trait one as well?

    Same deal?

     
  • Archid

    Archid - 2015-02-03

    No, it wouldn't clash as the tags all go in the ImprovementInfo.

    We could make the Civic & Traits AND or OR with regard to requirement but the spawn rate would be independent so both would apply.

     
  • Archid

    Archid - 2015-02-03
    • status: open --> for-test
     
  • Lib Spit

    Lib Spit - 2015-02-03

    LOVE IT!

     
  • Archid

    Archid - 2015-02-04
    • assigned_to: Lib Spit
     
  • Lib Spit

    Lib Spit - 2015-06-03

    At the moment there is no text for Improvement spawning stuff in the Civic Screen, at the moment I am using the help text to apply it, but an automated feature like for other stuff (Unit cost changes, building prereqs, etc.) Would be great to have!

    Also it seems that the spawn code is broken, I just made farms spawn units when built when militia civic is active, but now when a unit touches a garden tile, the garden is destroyed as a lair.. Also it seems the 'civic requirement' doesn't seem to have any effect either, as the garden spawns a unit whether the civic is active or not..

    Can we remove lair destruction, and just use the standard pillage system?

     

    Last edit: Lib Spit 2015-06-03

Log in to post a comment.