Menu

How to define starting locations

Developers
2009-03-27
2013-04-15
  • Albert Willburt

    Albert Willburt - 2009-03-27

    Hi,

    I wanted to know how I can define the starting location of my units, so for example two armies face each other. Right now I wanted to generate a map where two armies face each other (similar to the tournament maps) but when I generate the map the units apear scattered troughout the map.

     
    • Albert Willburt

      Albert Willburt - 2009-03-27

      Sorry about the location of the post, should have posted it in the Help section.

       
    • Tim

      Tim - 2009-03-28

      Depending on what you need you could add "-split" to the flags used for game5.  If you want a larger spacing between armies you'd need to edit MapMarine.C (near the end).

      I'm assuming the game5 "marine" maps are fairly close to what you want.  If you want to get rid of the sheep you can just comment out the global "shepherd" object.

      Otherwise the object-creation portion of TournamentMapTool.C should be fairly readable.

       
    • Albert Willburt

      Albert Willburt - 2009-04-26

      After your advice things got a lot easier but now I have more questions :(. What I'm doing at the moment is customizing the TournamentMapTool.C to generate the terrain and now I need to end the game (by timeout or KO) and then send a custom made score (I'm using genetic algorithms so this would be my own fitness evaluation function). So my questions can be resumed to the following:

      Tournament maps implement two mechanisms trough .bp that allow the game to end. They also use blueprints to customize object attributes. How can I use/customize/create similar methods? Should implement them in game.C or is there an easier way?

      Thanks in advance :D

       
      • Tim

        Tim - 2009-04-26

        OK, so I'm hearing that you've read game2.bp and looked over the timer class that's responsible for ending the game and printing out some statistics.  The shared "sk" object defined in common/scorekeeper.bp is keeping track of unit creations and kills (you can grep for "shared.sk" in the tournament .bp files).

        Presumably you want to be starting your game similar to the tournament-2008/game2_orts script (using "-bp" to specify a modified set of blueprints).

        You should be able to just copy the tournament-2008 files and make changes to the relevant .bp files.

        Perhaps an example would help me see where you're having trouble.  If you need something really arcane it could involve creating a C function and exposing it to the scripts -- if that's the case it might be worthwhile for me to add it to the main trunk.

         
    • Albert Willburt

      Albert Willburt - 2009-04-26

      Nice, if I can use the blueprints then I'll use them since they're pretty much complete and as long as the timers trigger the FINISHED_MSG event they're perfect :).

      About the score, the one I need to implement is quite simple and at the same time a bit tricky, basically my score is damage done minus damage received. First I was thinking of just waiting for the game to end and let my eventHandler calculate the score by checking the remaining hp and missing units. The problem is that it won't work when my units loose with fog of war :/. I checked out the scorekeeper and it only keeps track of units lost but there can still be enemy damaged units in the field, also If I used the shared sk variable I would need access to inside my eventHandler (so I can update my GA with the score), any ideas/suggestions?

       
      • Tim

        Tim - 2009-04-27

        No problems.

        You can get a pointer with PlayerInfo::shared_obj("sk").  From there, sk->component("damage") to get the vector containing the damage info.  Vector class is described in ScriptVector.H -- seems the raw data is public anyway, just call SType::to_int().

        You'll need to add the "damage" vector by editing deal_damage() in common/weapons.bp and the scorekeeper.

        Something like:

          if (dmg > targ.hp) dmg = targ.hp;
          shared.sk.damaged_by(targ; this.parent.owner, dmg);

        --------
          class Vector damage

          action damaged_by(a;p,d;) {
            this.damage[a.owner] += d;
          }

         
    • Albert Willburt

      Albert Willburt - 2009-04-27

      Awesome, I'll give it a shot then. Thanks!

       
    • Albert Willburt

      Albert Willburt - 2009-04-27

      I'm having some trouble with the timers, it seems that the game does end but the client never receives the FINISHED_MSG event. Instead it terminates when he detects that the TCP connection was closed.

      I tried to send a second message to the client (in Server.C after he detects the game is over) but I was unsuccessful. How do I send the updated game view to the client before the TCP connection closes?

       
      • Tim

        Tim - 2009-04-28

        Seems there was never an explicit "end game" message in the protocol.  I've updated the code, and it seems to be working now.  The clients should receive the very final game state, and a FINISHED_MSG is triggered.

        Let me know if things don't work as expected.

         

Log in to post a comment.