Announcement

Collapse
No announcement yet.

Several source code questions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Several source code questions

    In the course of my work I've came across a number of unresolved questions about how to do things. It occurred to me that there might be people here who happen to know the answers, saving me the time of rediscovering them.

    1. How can I get information about the results of an event added? For example, when ordering an army to settle its current location, I add a GEV_SettleOrder to the GameEventManager. I would like to know whether or not this was successful and, if so, the index into my city array representing the new city.

    2. Similarly, when I would like to initiate a combat, I call Army::Fight(), which returns void. I would like to be able to report whether or not my army was victorious.

    (By the way, much of this code I inherited, and I would be glad to change it if there is a better way to accomplish what I am attempting.)

    3. I have been using as an identifier an index into Player::m_all_armies, so that the external agent can specify things that should be done to a specific army. Unfortunately, it appears that (as you would expect) the elements of these arrays slide down to fill in spaces when an army is killed/disbanded/etc. Is there a more permanent ID that I can store and use after some number of turns with a guarantee that it refers to the same army?

    4. There are a number of message that pop-up during the game to provide information but do not require a choice to be made. (For example, a notice that an opponent has started building a wonder, or a report on the results of entering a goody hut.) Is there a way I can suppress the creation of these pop-ups for non-interactive games, or cause them to automatically close?

    Thanks so much for taking the time to read this and (hopefully) for your response!

    Chad Hogg

  • #2
    1. I think this can be found in ArmyEvent but I've had trouble myself trying to make sure it ties to things (i.e. there is some capture city code in armyevent.cpp but it doesnt get called for some reason)

    2. IIRC fight reiterates until no defender or attacker is left. If you want a victory report you might have to add a slic message or a return line. AFAIK the game doesn't report victories.

    3. I don't think so. But why are you doing it? You can create code to do it, I'm sure we'll find a use for it

    4. The only way around this is to go to the script.slc file and remove all the Show() lines I *think*. There might also be a property of the alertboxes as opposed to message boxes. I think alertboxes automatically show up. You can shange alert boxes to messageboxes (with Replace all) and it shouldn't break anything. I guess it would be nice to have a disable pop-up option but I'm not sure how to implement it.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

    Comment


    • #3
      Thank you for your response. Just a few hours ago I figured out how to add a subclass of GameEventHookCallback to occur whenever certain events happen (such as GEV_SettleOrder, GEV_Settle, and GEV_CreateCity for the circumstances of question 1). I haven't quite got this working yet, but it seems promising. I am thinking I should be able to do the same type of thing for question 2 with events GEV_FinishAttack, GEV_Battle, GEV_BattleAftermath, or GEV_KillUnit.

      By the way, line 62 of GameEventDescription.h, reproduced below, added some humor to an otherwise depressing day. Kudos to whomever wrote it!

      EVENT(SoothsayOrder, "Army says sooth. \"Sooth!\" says Army, \"Sooth!\"", "%a%l")

      As for question number 3, I want my agent to be able to store a model of the world as he perceives it so that I do not need to re-update him with the existence of all his units, etc on each turn. This becomes rather difficult if (for example) units do not have an unchanging identifier by which the agent can tell me to move or attack with or whatever. Given enough time and no better solution, I probably will end up coding something like this. If so (and with anything that appears to have uses beyond what I am doing) I will be sure to release it back to the community.

      Simply editing the script files to remove the messages should be a fine answer to question 4, at least for now. If this project continues very far into the future it might be nice to add code to specify a completely interaction-less mode where the user simply watches the game unfold as my agent(s) battle the built-in AI.

      Comment


      • #4
        Re: Several source code questions

        Originally posted by chadhogg
        3. I have been using as an identifier an index into Player::m_all_armies, so that the external agent can specify things that should be done to a specific army. Unfortunately, it appears that (as you would expect) the elements of these arrays slide down to fill in spaces when an army is killed/disbanded/etc. Is there a more permanent ID that I can store and use after some number of turns with a guarantee that it refers to the same army?
        chadhogg, I think there might be a way to do this. The game appears to assign an army a charactered name. If you can track stuff by armyname it might do wht you want
        Formerly known as "E" on Apolyton

        See me at Civfanatics.com

        Comment


        • #5
          Originally posted by E
          4. The only way around this is to go to the script.slc file and remove all the Show() lines I *think*. There might also be a property of the alertboxes as opposed to message boxes. I think alertboxes automatically show up. You can shange alert boxes to messageboxes (with Replace all) and it shouldn't break anything. I guess it would be nice to have a disable pop-up option but I'm not sure how to implement it.
          If you say that is the only way then I have to note that this is simply wrong. In order to run the game automaticly without interference of such message boxes you can use the chat window command /rnd.

          To use it open the chat window by typing the apostrophe key (') and enter: /rnd x

          x is the number of turns you which to play automaticly. The auto turn loop can be stopped by using the escape key.

          To other commands are /attach n and /detach n.

          n here is the player number you want to turn into a robot. And n must be element of [0,9]. However I prefer to switch to the Barbarians instead of doing this, because if I remember correctly this does not work so well.

          -Martin
          Civ2 military advisor: "No complaints, Sir!"

          Comment

          Working...
          X