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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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);
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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
Sorry about the location of the post, should have posted it in the Help section.
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.
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
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.
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?
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;
}
Awesome, I'll give it a shot then. Thanks!
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?
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.