Announcement

Collapse
No announcement yet.

How do I give a technology to a player?

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

  • How do I give a technology to a player?

    I can't believe such basic notion is so hard to pull off.
    Scanning through the API, I found one Team-related function that seems to be for doing something like that, but I can't get it to work, and I don't really get the team relation either. Another one I found was "pushResearch", but I can't get this one to work, either. Am I missing something obvious here?
    _____
    rezaf

    Check out my Forest planting mod or my Terrain adaption mod

  • #2
    Clarification required here:

    1. Do you want the player to have the tech at the start of the game?
    A. If so then use the World Builder to give the player the tech from the Technology tab of the Player Mode.

    OR,

    2. Do you want the player to receive the tech during play?
    A. If so then use python to set the tech during on event:
    Code:
    	def giveTech( self, iTech, iPlayer ):
    		"""Gives advance iTech to iPlayer."""
    		iTeam = gc.getPlayer(iPlayer).getTeam()
    		gc.getTeam(iTeam).setHasTech(iTech, True, 0, False, False)
    Dale

    Comment


    • #3
      Isn't your 0 argument supposed to be the player ID Dale?

      Here is the answer I posted at CFC:

      Depends on where you want to do it.

      Techs are a per-team thing - everyone on the same team has the same techs. You need to get the player's team object first which is done in most places by
      Code:
      iTeamID = gc.getPlayer(iPlayerID).getTeam()
      pTeam = gc.getTeam(iTeamID)
      With iPlayerID being the player ID that you want to give the tech to (obviously).

      Once you have pTeam there's a function to award techs
      Code:
      pTeam.setHasTech(iTechID, bNewValue, iPlayer, bFirst, bAnnounce)
      - iTechID is the tech number you want to give (defined by the order in XML).
      - bNewValue I'm not sure about, you can probably pass in true and it'll be okay.
      - iPlayer is the player who is getting the tech (iPlayerID in this case)
      - bFirst is whether or not this team is the first to get the tech (for things like awarding religions and great people)
      - bAnnounce I think is whether or not the fact that the team got the tech is announced to either that player/team or to everyone, I'm not sure which.

      Comment


      • #4
        Actually, yeah it should be. Sorry, I just copy/pasted it straight from Desert War and that's an English tech give (which is player 0).

        Dale

        Comment


        • #5
          Shame! Hard-coding/hacking values == bad!

          Comment


          • #6
            Ahhh....... bit like this one from Am Rev?

            aiUnitPlot = self.findUnitPlacementPlot(self.iFrenchID, iXPlot, iYPlot, false, true, 2)

            Dale

            Comment


            • #7
              I actually corrected that last week.

              Comment


              • #8
                As I wrote in the CFC thread, I got it to work with your advice Trip, thanks a bunch.

                Finished my next mini-mod with being able to distribute techs. *scratches one off the list*

                Thanks again.
                _____
                rezaf

                Check out my Forest planting mod or my Terrain adaption mod

                Comment


                • #9
                  If I'm understand the question, I think you are going about it the hard way.

                  Just mod the civ4civilizationsinfos.xml file:

                  [FreeTechs]
                  [FreeTech]
                  [TechType]TECH_MYSTICISM[/TechType]
                  [FreeTech]1[FreeTech]
                  [/FreeTech]
                  [/FreeTechs]


                  *why is it so hard to post codes here?*

                  Comment


                  • #10
                    You are NOT understanding the question.

                    Seriously though, I didn't simply wanna throw around free techs at the game start but I wanted to add them under certain circumstances. Take a look at my Adaption Mod to see what I needed this for.
                    _____
                    rezaf

                    Check out my Forest planting mod or my Terrain adaption mod

                    Comment

                    Working...
                    X