Announcement

Collapse
No announcement yet.

City Expansion mod

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

  • #16
    I am pretty sure you are having the same old crazy bug. Try this ExpandCity function:
    Code:
    int_f ExpandCity(int_t owner, location_t cityLoc, int_t cityRadius, int_t tileType, int_t addDelete) {
    location_t	tmpLoc;
    location_t	tmp2Loc;
    int_t		i;
    int_t		j;
    int_t		k;
    int_t		sucess;
    int_t		newType;
    int_t		searchRadius;
    int_t		addDeleteYN;
    int_t		ownerNum;
    
    	if (FAI_INIT == 1000)
    	{
    		searchRadius = 1;
    		sucess = 0;
    		newType = tileType;
    		addDeleteYN = addDelete;
    		ownerNum = owner;
    		j = random(6);
    		if (j == 0 || j == 5 || j == 2 || j == 7) {
    			j = 6;
    		}
    		while (searchRadius <= cityRadius && sucess == 0) {
    			tmpLoc = cityLoc;
    			for (k = 0; k < searchRadius; k = k + 1) {		
    				GetNeighbor(tmpLoc, j, tmp2Loc);
    				tmpLoc = tmp2Loc;
    			}
    			if (HasAdvance(owner, ID_ADVANCE_TOOLMAKING)
    			 && !HasAdvance(owner, ID_ADVANCE_CONCRETE)
    			 && !HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS)
    			 && !HasAdvance(owner, ID_ADVANCE_EUGENICS)
    			 && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) {
    				sucess = ReplacePCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN);
    			} 
    			elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING)
    			 && HasAdvance(owner, ID_ADVANCE_CONCRETE)
    			 && !HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS)
    			 && !HasAdvance(owner, ID_ADVANCE_EUGENICS)
    			 && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) {
    				sucess = ReplaceACTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN);
    			} 
    			elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING)
    			 && HasAdvance(owner, ID_ADVANCE_CONCRETE)
    			 && HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS)
    			 && !HasAdvance(owner, ID_ADVANCE_EUGENICS)
    			 && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) {
    				sucess = ReplaceMCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN);
    			} 			
    			elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING)
    			 && HasAdvance(owner, ID_ADVANCE_CONCRETE)
    			 && !HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS)
    			 && !HasAdvance(owner, ID_ADVANCE_EUGENICS)
    			 && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) {
    				sucess = ReplaceACTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN);
    			} 
    			elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING)
    			 && HasAdvance(owner, ID_ADVANCE_CONCRETE)
    			 && HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS)
    			 && HasAdvance(owner, ID_ADVANCE_EUGENICS)
    			 && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) {
    				sucess = ReplaceGCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN);
    			} 			
    			elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING)
    			 && HasAdvance(owner, ID_ADVANCE_CONCRETE)
    			 && HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS)
    			 && HasAdvance(owner, ID_ADVANCE_EUGENICS)
    			 && HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) {
    				sucess = ReplaceALTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN);
    			}
    			i = j + 1;
    			while (i != j && sucess == 0) {
    				tmpLoc = cityLoc;
    				for (k = 0; k < searchRadius; k = k + 1) {		
    					GetNeighbor(tmpLoc, i, tmp2Loc);
    					tmpLoc = tmp2Loc;
    				}
    							if (HasAdvance(owner, ID_ADVANCE_TOOLMAKING)
    			 && !HasAdvance(owner, ID_ADVANCE_CONCRETE)
    			 && !HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS)
    			 && !HasAdvance(owner, ID_ADVANCE_EUGENICS)
    			 && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) {
    				sucess = ReplacePCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN);
    			} 
    			elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING)
    			 && HasAdvance(owner, ID_ADVANCE_CONCRETE)
    			 && !HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS)
    			 && !HasAdvance(owner, ID_ADVANCE_EUGENICS)
    			 && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) {
    				sucess = ReplaceACTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN);
    			} 
    			elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING)
    			 && HasAdvance(owner, ID_ADVANCE_CONCRETE)
    			 && HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS)
    			 && !HasAdvance(owner, ID_ADVANCE_EUGENICS)
    			 && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) {
    				sucess = ReplaceMCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN);
    			} 			
    			elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING)
    			 && HasAdvance(owner, ID_ADVANCE_CONCRETE)
    			 && !HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS)
    			 && !HasAdvance(owner, ID_ADVANCE_EUGENICS)
    			 && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) {
    				sucess = ReplaceACTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN);
    			} 
    			elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING)
    			 && HasAdvance(owner, ID_ADVANCE_CONCRETE)
    			 && HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS)
    			 && HasAdvance(owner, ID_ADVANCE_EUGENICS)
    			 && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) {
    				sucess = ReplaceGCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN);
    			} 			
    			elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING)
    			 && HasAdvance(owner, ID_ADVANCE_CONCRETE)
    			 && HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS)
    			 && HasAdvance(owner, ID_ADVANCE_EUGENICS)
    			 && HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) {
    				sucess = ReplaceALTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN);
    			}
    					sucess = ReplaceALTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN);
    				}
    				i = i + 1;
    				if (i == 8) {
    					i = 0; 
    				}
    			}
    			searchRadius = searchRadius + 1;
    		}	
    		return sucess;		
    	} else {
    		return 0;
    	}
    }
    Note: I got game crashs when when i added the medieval age function.
    Last edited by Pedrunn; August 2, 2002, 17:50.
    "Kill a man and you are a murder.
    Kill thousands and you are a conquer.
    Kill all and you are a God!"
    -Jean Rostand

    Comment


    • #17
      IW, my code is working fine.
      The only problem is the CreateUnit event that doesnt work (damn activision) and the pillaging.
      The first isnt a big deal since for all mods only the settlers units kill pops when built.
      Yet, have you tried the pillaging? Any lucky?

      Please, say you have good news!
      "Kill a man and you are a murder.
      Kill thousands and you are a conquer.
      Kill all and you are a God!"
      -Jean Rostand

      Comment


      • #18
        ok.
        Does the ReduceCity1/4 function work when called by other events, such as plague or conquest? If it does, and it is just the CreateUnit event that is buggy, then could you repost your complete code and tileimp.txt - without the wonders in, I want to keep that separate.

        I'll have a look at the pillaging some more.
        Concrete, Abstract, or Squoingy?
        "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

        Comment


        • #19
          Here it is.

          I took the create wonders fuction off the code but i kept the fuction to prevent the creation of cities over them (The very first one: "TileHasWonder").
          If you want it out too just tell me.

          EDIT: One funny thing, the CaptureCity Event is known to work nicely. As we can see in the partisan code, the new capture option code and many others. But it does not seems to work with the ReduceCity function . What you think?
          Attached Files
          Last edited by Pedrunn; August 6, 2002, 13:12.
          "Kill a man and you are a murder.
          Kill thousands and you are a conquer.
          Kill all and you are a God!"
          -Jean Rostand

          Comment


          • #20
            IW, Did you get a solution for pillaging?
            "Kill a man and you are a murder.
            Kill thousands and you are a conquer.
            Kill all and you are a God!"
            -Jean Rostand

            Comment


            • #21
              I feel so stupid. Indeead i cant get the PillageOrder and PillageUnit to work. But the CutImprovements do work. my trouble was that i used a local variable to call the location variable of the event. when i used the built in variable location[0] all worked nicely.
              Last edited by Pedrunn; August 11, 2002, 22:33.
              "Kill a man and you are a murder.
              Kill thousands and you are a conquer.
              Kill all and you are a God!"
              -Jean Rostand

              Comment


              • #22
                Excellent. I just came by to find that picture you posted, again. I lost it last time. So I take it the pillaging does now work?

                Oh, about that bug in the CaptureCity event, I think it is because the city owner is changing across the course of that handler. Set the handler to post, rather than pre, and the owner will be the conqueror, and when the expand city code fires, the tile improvement will be able to be built by the new owner, in the new owner's territory.

                I think.

                I figured out the bug in the wonder code, so I'll get this lot wrapped up, and release it again.

                Pedrunn, unless you want me to continue administering to the tile files, and the overall conception of this, its your mod: most of the graphics are yours, its your code.
                I'm happy to write the readme and collect it all together, but its your decision.
                Concrete, Abstract, or Squoingy?
                "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

                Comment


                • #23
                  Originally posted by Immortal Wombat
                  Excellent. I just came by to find that picture you posted, again. I lost it last time. So I take it the pillaging does now work?.
                  Yep it work fine except for a small bug. The CutImprovents event only prevents the TI to be cutted. yet pillage still happen (the effect and the unit looses movements). This makes the AI try to pillage over and over and over every turn although Imps remains untouched. So i am making a function to make the units move out of this TI.

                  Originally posted by Immortal Wombat
                  Oh, about that bug in the CaptureCity event, I think it is because the city owner is changing across the course of that handler. Set the handler to post, rather than pre, and the owner will be the conqueror, and when the expand city code fires, the tile improvement will be able to be built by the new owner, in the new owner's territory.
                  I will try this. But i am feeling this will work out. since the city owner has to be also the owner of the terrain where the city imp is going to be added. And that is where the problem lies.
                  Originally posted by Immortal Wombat
                  I figured out the bug in the wonder code, so I'll get this lot wrapped up, and release it again.
                  I did not got what you meant by this. Are you going to give up of your code and use mine? Or will you fix it?
                  Originally posted by Immortal Wombat
                  Pedrunn, unless you want me to continue administering to the tile files, and the overall conception of this, its your mod: most of the graphics are yours, its your code.
                  I'm happy to write the readme and collect it all together, but its your decision.
                  To tell you the truth i have already made some changes in the til file so i do want to take care of the til nad control whoever wants to add new things to it.
                  I can do the read me but i prefer that you make it. you have a better english and i am starting to get busy here with real life, the religion code, City expansion and the GL of my mod that never finishs). So do you want to take the read me work?

                  PS: There seems to be a imcompatibility with the Martin's new capture options code. No matter what i change in both codes I cant get the surrouding suburbs to reduce if the city is bloodbath, enslaved or evacueted. I will attach the new code soon so that you can give it a shot too.
                  "Kill a man and you are a murder.
                  Kill thousands and you are a conquer.
                  Kill all and you are a God!"
                  -Jean Rostand

                  Comment


                  • #24
                    Originally posted by Pedrunn
                    Yep it work fine except for a small bug. The CutImprovents event only prevents the TI to be cutted. yet pillage still happen (the effect and the unit looses movements). This makes the AI try to pillage over and over and over every turn although Imps remains untouched. So i am making a function to make the units move out of this TI.
                    Maybe you have to check PillageUnit and PillageOrder event. As I wrote this little slic code I was happy that it avoided the crash, so far I never saw an AI of pillaging again and again. Maybe this was caused by the fog of war.

                    Originally posted by Pedrunn
                    PS: There seems to be a imcompatibility with the Martin's new capture options code. No matter what i change in both codes I cant get the surrouding suburbs to reduce if the city is bloodbath, enslaved or evacueted. I will attach the new code soon so that you can give it a shot too.
                    It looks that your code has to trigger on the KillCity and on the KillPop events. And note that I did some changes for mapfi recently. You find the newest version in the accoring thread in the CTP2 general forum.

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

                    Comment


                    • #25
                      You got it right IW . the CaptureCity works now

                      Martin, I got the new code but it still does not work .
                      It looks that your code has to trigger on the KillCity and on the KillPop events
                      Those event are included in the code. They should have been triggered.

                      Maybe you have to check PillageUnit and PillageOrder event. As I wrote this little slic code I was happy that it avoided the crash, so far I never saw an AI of pillaging again and again. Maybe this was caused by the fog of war.
                      What slic code you wrote?
                      I've tried not succefully those two functions. And cant be fog of war. I just placed a barb unit close to deads cities TI in the firsts turns. He went to the TI location and started to try pillaging the TI every turn.
                      "Kill a man and you are a murder.
                      Kill thousands and you are a conquer.
                      Kill all and you are a God!"
                      -Jean Rostand

                      Comment


                      • #26
                        Originally posted by Martin Gühmann
                        so far I never saw an AI of pillaging again and again. Maybe this was caused by the fog of war.
                        You were right. The AI doenst keeping pillage endless.
                        Its unit keeps trying pillaging for several turns (about five) and them give up. So this is not a problem.
                        "Kill a man and you are a murder.
                        Kill thousands and you are a conquer.
                        Kill all and you are a God!"
                        -Jean Rostand

                        Comment


                        • #27
                          It could be removed entirely by adding an extra strategy that kicked in when it started pillaging suburbs. It only needs one component - the pillage goal with a priority, maxeval and maxexec of 0.

                          But I still think you should be able to pillage them.
                          Concrete, Abstract, or Squoingy?
                          "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

                          Comment


                          • #28
                            Actually when you pillage them they turn to ruins. But the AI keeps pillaging them when they are ruins. And i dont want ruins to be pillaged.
                            "Kill a man and you are a murder.
                            Kill thousands and you are a conquer.
                            Kill all and you are a God!"
                            -Jean Rostand

                            Comment


                            • #29
                              Ah. Yes, good point. Kill them, and blame bandits.
                              Concrete, Abstract, or Squoingy?
                              "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

                              Comment


                              • #30
                                "Kill a man and you are a murder.
                                Kill thousands and you are a conquer.
                                Kill all and you are a God!"
                                -Jean Rostand

                                Comment

                                Working...
                                X