Random Turn Event: Monster Spawn

Creation, discussion, and balancing of game content such as techs, buildings, ship parts.

Moderators: Oberlus, Committer

Post Reply
Message
Author
User avatar
Sloth
Content Scripter
Posts: 685
Joined: Sat Mar 17, 2007 12:28 am

Random Turn Event: Monster Spawn

#1 Post by Sloth »

In order to get used to the new python random turn events enabled by Vezzra, i wrote this (very minor) event that adds a Floater or Space Krill to a random empty system (no Planets, no Fleets). I've opted to start very conservative to not mess with the players plans too much (big splashy events that turn everything topsy-turvy have to wait for the future).

But before we go on discussing cool new events (which we should do in the future), i would like to ask whether my small event should be added. At the very least it will be another scripting example for future events.

Feel free to voice balancing concerns, code style violations, (small) expansion wishes, etc.

Code: Select all

    gsd = fo.get_galaxy_setup_data()
    # creating monsters
    monster_freq = fo.monster_frequency(gsd.monsterFrequency)
    # monster freq ranges from 30 (= one monster per 30 systems) to 3 (= one monster per 3 systems)
    # (example: low monsters and 150 Systems results in 150 / 30 * 0.001 = 0.005)
    if monster_freq > 0 and random() < len(systems) / monster_freq * 0.001:
        if random() < 0.3:
            monster_type = "SM_KRILL_1"
        else:
            monster_type = "SM_FLOATER"

        print "...creating new", monster_type

        # search for systems without planets or fleets
        candidates = [s for s in systems if len(fo.sys_get_planets(s)) <= 0 and len(fo.sys_get_fleets(s)) <= 0]
        system = choice(candidates)
        # if system selection fails, report an error
        if system == fo.invalid_object():
            util.report_error("Python execute_turn_events: unable to find system for monster spawn")

        # create monster fleet
        monster_fleet = fo.create_monster_fleet(system)
        # if fleet creation fails, report an error
        if monster_fleet == fo.invalid_object():
            util.report_error("Python execute_turn_events: unable to create new monster fleet at %s" % system)
        else:
            # create monster, if creation fails, report an error
            monster = fo.create_monster(monster_type, monster_fleet)
            if monster == fo.invalid_object():
                util.report_error("Python execute_turn_events: unable to create monster %s" % monster_type)
All released under the GNU GPL 2.0 and Creative Commons Attribution-ShareAlike 3.0 licences.

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Random Turn Event: Monster Spawn

#2 Post by MatGB »

I definitely like the idea of krill just turning up, not so sure about floaters, they've got a game based mechanism already.

But one thing we are missing is a source of Vacuum Dragons, only, um, they're a bit scary...
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Sloth
Content Scripter
Posts: 685
Joined: Sat Mar 17, 2007 12:28 am

Re: Random Turn Event: Monster Spawn

#3 Post by Sloth »

MatGB wrote:I definitely like the idea of krill just turning up, not so sure about floaters, they've got a game based mechanism already.
You are right, Floaters can spawn for longer in the game with the help of Dyson Forests, while Krill usually dies out very quickly. I really like the Floaters and Dyson Forests though (and have some vague plans to expand them). Maybe change the chances to more Krill and less Floaters?
MatGB wrote:But one thing we are missing is a source of Vacuum Dragons, only, um, they're a bit scary...
I had a version that spawned Vacuum Dragons (with a turn threshold), but they really need some more checks to not be placed into the way of a passing fleet. This would need some more c++ functions exposed and/or more complicated python code, which i don't want to tackle right now (but like to do in the future).
All released under the GNU GPL 2.0 and Creative Commons Attribution-ShareAlike 3.0 licences.

User avatar
Sloth
Content Scripter
Posts: 685
Joined: Sat Mar 17, 2007 12:28 am

Re: Random Turn Event: Monster Spawn

#4 Post by Sloth »

I've created a PR: https://github.com/freeorion/freeorion/pull/277

The chance for Krill is now 70% and Floater 30%.
All released under the GNU GPL 2.0 and Creative Commons Attribution-ShareAlike 3.0 licences.

Post Reply