Announcement

Collapse
No announcement yet.

telling a unit to Goto a specific plot

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

  • telling a unit to Goto a specific plot

    I'm trying to find out the nearest city to a unit and then have that unit go there, as if you selected the unit and then gave it the Goto command to go there.

    It's easy to get a list of your cities and details on the unit you have selected but I can't figure out how to both:

    1. Determine how many turns it would take for a unit to get to a specific plot

    and

    2. Give the unit a Goto command to go there


    CyUnit has a canMoveInto function was was nice but doesn't tell me anything about how many turns it would take

    and CyPlot has a movementCost function which asks for a a CyUnit and the CyPlot it would be coming from but that gave me the same number for every city- 30.

    Any ideas?

    edit: Oh yeah and CySelectionGroup had an interesting function:

    VOID pushMission(MissionType eMission, INT iData1, INT iData2, INT iFlags, BOOL bAppend, BOOL bManual, MissionAIType eMissionAI, CyPlot pMissionAIPlot, CyUnit pMissionAIUnit)

    And MOVE_TO is a MissionType, but I have no idea what the following parameters mean:

    iData1
    iData2
    iFlags
    bManual
    pMissionAIUnit

    I'm assuming if I did a MOVE_TO mission the pMissionAIPlot is the destination, append just means whether it should be added to a qeueue of mission (?)

  • #2
    OK! That works using pushMission... I still don't know what the last two parameters are for... I just put NO_MISSIONAI as the MissionAIType so I hope it doesn't even use the last parameters (I just passed the current plot and current unit)

    But I still need to figure out how many turns a unit would take to get to a specific plot / x,y coord!

    I have no ideas about that one

    Comment


    • #3
      There is another interesting function which I tried using:

      BOOL generatePath(CyPlot pFromPlot, CyPlot pToPlot, INT iFlags, BOOL bReuse, INT piPathTurns)

      but when I try to use it I get the following error:

      TypeError
      :
      this constructor takes no arguments

      not sure what that means as I am not too familiar with debugging errors from Python.

      I passed to this function:

      the selected unit's plot
      the plot of one of my cities
      0
      tried both True & False
      for piPathTurns tried 0, 1

      I was hoping piPathTurns would be set to how many turns it takes for the units to get to the location

      Comment


      • #4
        hmm, if I do pretty much the same thing but using the Python console inside the game, I get the following error:

        It's different this time, says my arguments don't much. What's wrong with my arguments? Besides the fact the C++ is looking for a pointer....

        Attached Files

        Comment


        • #5
          I'm also try to deal with the pushMission method, but I always get a message that the c++ signature does not match. I can't find the reason, so could you post (or pm or email) me a code sample, please? Also, did you find out what those parameters (iData1, iData2, iFlags, bAppend, bManual) are for?
          Have a look on my mods :
          Modified Special Domestic Advisor 1.8b !!! UPDATE !!!
          Plot List Enhancement
          Restart interceptor animation after game load

          Comment


          • #6
            never mind! problem already solved!

            thx anyway
            Have a look on my mods :
            Modified Special Domestic Advisor 1.8b !!! UPDATE !!!
            Plot List Enhancement
            Restart interceptor animation after game load

            Comment


            • #7
              The C++ error message makes me think piPathTurns should be a variable, not a number; the function will probably fill in how many turns the path takes.

              Comment


              • #8
                Originally posted by 12monkeys
                never mind! problem already solved!

                thx anyway
                So what did you do to make it work?

                I never got that function working, I simply gave up on it and used a work-around

                Comment


                • #9
                  there were two things I changed, but I don't know which one of them is the real reason why it suddenly works (may both are required) :

                  1.) The c++ signature is as follows :

                  VOID pushMission(MissionType eMission, INT iData1, INT iData2, INT iFlags, BOOL bAppend, BOOL bManual, MissionAIType eMissionAI, CyPlot pMissionAIPlot, CyUnit pMissionAIUnit)

                  At the beginning I did a call like that :

                  pushMission(5, 0, 0, 0, false, false, -1, pPlot, pUnit)

                  That means I used a 5 and -1 for the mission types.

                  Then I changed it to the Civ constants MissionTypes.MISSION_AIRPATROL and MissionAITypes.MISSION_NOAIMISSION :

                  pushMission(MissionTypes.MISSION_AIRPATROL, 0, 0, 0, false, false, MissionAITypes.MISSION_NOAIMISSION, pPlot, pUnit)

                  I don't think that this is the reason for the signature problem because the signature indicates a call-by-value.


                  2.) First I modified the CyEventManager.py file for my change. Then I moved the complete procedure into a seperate class and imported that class within CyEventManager.py


                  As I said, both things were done in parallel, I can't specifiy which one is the real cause.

                  You can check a code sample here
                  Have a look on my mods :
                  Modified Special Domestic Advisor 1.8b !!! UPDATE !!!
                  Plot List Enhancement
                  Restart interceptor animation after game load

                  Comment


                  • #10
                    Ohh I'm sorry you were talking about pushMission! I thought you got generatePAth working!

                    YEah I got pushMission working out actually

                    I did something like a MissionType.GOTO or MOVE or whatever it is.

                    iData1 and iData2 are variables specific to the mission type so they may or may not be used. For any movement-specific mission types, they are used for coordinates. So iData1 = x-coordinate and iData 2 = y-coordinate of the plot you want that unit to move to.

                    iFlags is I don't know, I always set it to 0.

                    bManual? I figure this has something to do with the AI so I set this to true and then for pMissionAIPlot and pMissionAIUnits I just set them to the current unit and the unit's current plot, figuring the function won't use them since I set bManual to true.

                    bAppend has to do with the mission queue. Each unit's group can queue up mission so if you set bAppend to true it will append to end of queue otherwise if you set it to false it looks like it makes this mission the current mission.

                    Comment


                    • #11
                      pushMission (attack)

                      Anyone knows what the “iFlag” variable do?
                      I want to force a unit to attack a certain enemy unit next to my unit.
                      I also use the pushMission command.
                      It’s no problem to let the unit use the fortify, airpatrol or move to a certain plot with the pushMision command but I don’t know how I can force my unit to attack the enemy unit. ( I tried the mission_move_to, mission_move_to unit, mission_begin_combat lines but the unit didn’t attack

                      Someone can help??

                      Comment

                      Working...
                      X