Announcement

Collapse
No announcement yet.

Babarian Encampments SLIC idea

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

  • #16
    Hey great, i hope this does work, i havent actually tested it as i dont know how
    Copy and paste the code into scenario.slc
    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


    • #17
      Actually i have a improved version of this code already. Yet not tested too wich only the camps get destroyed and not the captured cities too.
      The camp only is destroyed in the beginning of the barbarian turn. It is like: Start Barbarian turn -> Destroy All Camps -> Barbarians move units -> End Barbarian Turn - Create Camps where there are barbarians units -> the non-barbs civs start their turns -> the non-barb civs dont see any barb units in the map just camps -> End non-Barb Civ turn -> Begin Barbarians turn - Kill all camps -> Barbarians units moves -> End barbarian Turn -> Create Camps where there is a barb unit.

      I will test it today since no one did it until now. But if you can please do. I am a bit busy with city expansion code.
      "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
        I had to choose between slic work or my girlfriend, yesterday .
        Sorry guys .

        Probably i wont have time today too . Maybe tomorrow.
        "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


        • #19
          Originally posted by Pedrunn
          I had to choose between slic work or my girlfriend, yesterday .
          Sorry guys .

          Probably i wont have time today too . Maybe tomorrow.
          I'm guessing you got the same results I did: it still didn't do anything.

          Has anyone confirmed that CreateCity works as advertised? For that matter does ImprovementComplete?

          Comment


          • #20
            All the events with these GEA_ arguments can't be triggered in slic. You can only trigger event handler by this event unfortunatly I get error index of bounce errors if I use this event to trigger my code and try to use a build in array with DebugSlic=Yes. If it is just saved in a user defined variable no problem, but if you try to use this variable no change. So you have to use the CreateImprovement event and have to trigger an event handler by this event that will execute the FinishImprovements function.

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

            Comment


            • #21
              I fee such a jerk. I have finished this code but isntead of cities it is created Tile Improvements.

              Add this in any .slc file of the mod you want to use it.
              Code:
              //////////////////////////////////////////////////////////////////////////
              //  5) Barbarian Camp 				  
              //	by Pedrunn  				 
              //////////////////////////////////////////////////////////////////////////
              
              int_t CampPlacement;
              
              HandleEvent(EndTurn) 'CreateBarbarianCamp' pre {			// When the player turn ends
              int_t i;
              int_t tmpPlayer;
              int_t ArmyCount;
              int_t CitySize;
              army_t	tmpArmy;
              location_t tmpLoc;
              
              player[0] = g.player;
              	if(player[0] == 0) {
              		ArmyCount = player[0].armies; 
              		for(i=0; i <= ArmyCount; i = i + 1) {		
              			GetArmyByIndex(0, i, tmpArmy);		// In all its armies
              			tmpLoc = tmpArmy.location;
              			if(CellOwner(tmpLoc) == -1) {			// if unit is in unclaimed land
              				CampPlacement = 1;
              				GrantAdvance(0, AdvanceDB(ADVANCE_SUBNEURAL_ADS));
              				Event:CreateImprovement(0, tmpLoc, TerrainImprovementDB(TILEIMP_BARBARIAN_CAMP), 0);
              			}
              			else{
              				tmpPlayer = CellOwner(tmpLoc);
              				CampPlacement = 1;
              				GrantAdvance(tmpPlayer, AdvanceDB(ADVANCE_SUBNEURAL_ADS));
              				Event:CreateImprovement(tmpPlayer, tmpLoc, TerrainImprovementDB(TILEIMP_BARBARIAN_CAMP), 0);
              			}
              		}
              	}
              }
              
              HandleEvent(CreateImprovement) 'BarbsCantHaveSubneuralAds' post {
              	if(CampPlacement == 1) {
              		CampPlacement = 0;
              		FinishImprovements(location[0]);
              		if (HasAdvance(player[0], ID_ADVANCE_SUBNEURAL_ADS)) {
              			RemoveAdvance(player[0], AdvanceDB(ADVANCE_SUBNEURAL_ADS));
              		}
              	}
              }
              
              HandleEvent(BeginTurn) 'DestroyBarbarianCamp' pre {			
              int_t i;
              int_t j;
              location_t tmpLoc;
              
              player[0] = g.player;
              	if(player[0] == 0) {
              		for (i=0; i<=GetMapWidth()-1; i=i+1) {
              			for (j=0; j<=GetMapHeight()-1 ; j=j+1) {
              				MakeLocation(tmpLoc, i, j);
              				if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_BARBARIAN_CAMP))) {	
              					Event: CutImprovements(tmpLoc);	
              				}
              			}
              		}
              	}
              }
              
              HandleEvent(BattleAftermath) 'Destroy2BarbarianCamp' pre {
              	if(TileHasImprovement(location[0], TerrainImprovementDB(TILEIMP_BARBARIAN_CAMP))){
              		Event:CutImprovements(location[0]);
              	}
              }
              and this in the bottom of the *_tileimp.txt of the same mod you want to use.
              Code:
              ############################################################
              
              TILEIMP_BARBARIAN_CAMP {
                 Icon ICON_TILEIMP_FORTIFICATIONS
                 Tooltip TOOLTIP_TILEIMP_SELECT_FORT_BUTTON
                 Statusbar STATUSBAR_TILEIMP_SELECT_FORT_BUTTON
                 Level 4
                 Class:Structure1
              
                 ConstructionTiles 1
              
                 CantBuildOn TERRAIN_WATER_BEACH
                 CantBuildOn TERRAIN_WATER_DEEP
                 CantBuildOn TERRAIN_WATER_RIFT
                 CantBuildOn TERRAIN_WATER_SHALLOW
                 CantBuildOn TERRAIN_WATER_SHELF
                 CantBuildOn TERRAIN_WATER_TRENCH
                 CantBuildOn TERRAIN_WATER_VOLCANO
              
                 TerrainEffect {
                    Terrain TERRAIN_BROWN_HILL
                    Terrain TERRAIN_BROWN_MOUNTAIN
                    Terrain TERRAIN_DESERT
                    Terrain TERRAIN_FOREST
                    Terrain TERRAIN_GLACIER
                    Terrain TERRAIN_GRASSLAND
                    Terrain TERRAIN_HILL
                    Terrain TERRAIN_JUNGLE
                    Terrain TERRAIN_MOUNTAIN
                    Terrain TERRAIN_PLAINS
                    Terrain TERRAIN_SWAMP
                    Terrain TERRAIN_TUNDRA
                    Terrain TERRAIN_WHITE_HILL
                    Terrain TERRAIN_WHITE_MOUNTAIN
              
                    DefenseBonus 0.5
                    EnableAdvance ADVANCE_SUBNEURAL_ADS
                    ProductionCost 0
                    ProductionTime 1
                    TilesetIndex 695
                 }
              }
              You must have the Apolyton Tile File.

              (* stands for the prefix of the mod and you will find these files to be changed in the
              CTP2 base director/ctp2_data/default/gamedata).
              "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
                aha, I thought I saw an extra one hiding at the end
                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
                  "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
                    Pedrunn:

                    Just wanted to let you know that I can quite happily confirm that CreateCity() & CreateCoastalCity() work absolutely perfectly. There's nothing wrong with the call, just how you used the args. You've got the right amount of args, but not the right ones.

                    CreateCity(player, location, distance[, holder]);

                    Where:
                    - player cannot be in the form: g.player, player[0].
                    - location cannot be an array element: army.location, city.location.
                    - distance is taken to me "somewhere between zero and X squares away".
                    - holder is not necessary, only if you want to do more with the city. Must be in form city_t.
                    - A city will not create within another city's radius. It puts it close to the location then.

                    Copy and paste the following code into scenario.slc, and start an original game. You should get a new city every couple of turns.

                    Code:
                    // Example CreateCity() & CreateCoastalCity() functions
                    
                    HandleEvent(BeginTurn) 'CreateCityTest' pre {
                         city_t tmpCity;
                         location_t tmpLoc;
                         int_t tmpPlayer;
                         int_t tmpDistance;
                         int_t tmpCounter;
                         city_t tmpCity;
                    
                         tmpDistance = 5;  // This is the distance from loc to build city
                         tmpPlayer = g.player;  // Current player
                         if(IsHumanPlayer(tmpPlayer)) {  // Only do for human
                         tmpCounter = random(4);  // <1 = CreateCity, >=3 = CoastalCity
                         if(GetCityByIndex(tmpPlayer, 0, tmpCity)) {
                              tmpLoc = tmpCity.location;
                              if(tmpCounter < 1) {
                                   if(!(CreateCity(tmpPlayer, tmpLoc, tmpDistance)) {  // Create the actual city.  You don't need a settler for this.
                                        return STOP;  // Error creating city
                                   }
                              }
                              if(tmpCounter >= 3) { // Create coastal city
                                   if(!(CreateCoastalCity(tmpPlayer, tmpLoc, tmpDistance)) {  // Create the actual city.  You don't need a settler for this.
                                        return STOP;  // Error creating city
                                   }
                              }
                         }
                    }

                    Comment


                    • #25
                      Thanks Dale. Thats som very imporant info. I did not tested my code with the CreateCity event But I will keep the code as TI (the last one) since there is TI has the advantages of being created inside another civilization borders without messing up the borders.
                      "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