Announcement

Collapse
No announcement yet.

IW, Could you help with one of yours Slics?

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

  • IW, Could you help with one of yours Slics?

    Code:
    city_t tmpCity;
    int_t tmpPlayer;
    int_t tmpWonder;
    
    
    void_f VeteranEffect (location_t tmpLoc, int_t tmpPlayer)
    {
    int_t	i;
    unit_t	tmpUnit;
    int_t	tmpNum;
    int_t	numUnits;
    int_t	tmpPlayer2;
    
    	player[0] = tmpPlayer;
    	numUnits = player[0].units;
    	tmpPlayer2 = tmpPlayer;
    	if (IsPlayerAlive(tmpPlayer2)) {
    	// Make all Units non veteran, except Special Units
    		for (i = 0; i < numUnits; i = i + 1) {
    			GetUnitByIndex(tmpPlayer2, i, tmpUnit);
    			tmpNum = tmpUnit.type;
    			if (tmpNum >= 106 && tmpNum <= 112) {                           
    				ToggleVeteran(tmpUnit, 1);
    			} else {
    				ToggleVeteran(tmpUnit, 0);
    			}
    		}
    	}
    	
    	// Make all Units veterans who share the location Alexander, Robin Hood and Richard The Lion Heart
    	tmpNum = GetUnitsAtLocation(tmpLoc);
    	for (i = 0; i < tmpNum; i = i + 1) {
    		GetUnitFromCell(tmpLoc, i, tmpUnit);
    		ToggleVeteran(tmpUnit, 1);
    	}
    }
    
    
    // Hammurabi
    
    HandleEvent(CreateWonder) 'Hammurabi' post {
    
    	tmpWonder = value[0];
    
    	if(tmpWonder == WonderDB(WONDER_HANGING_GARDENS)) {
    		tmpCity = city[0];
    		tmpPlayer = tmpCity.owner;
    		CreateUnit(tmpPlayer, UnitDB(UNIT_HAMMURABI), city[0].location, 0);
    		DisableTrigger('Hammurabi');
    	}
    }
    This is your Wonder Unit Code, IW. But could you make a small change. Instead of making the Wonder unit appear after finish building a Wonder could you make this unit appear after research an advance? Maybe appearing in the Capital City (or anywhere else if it became a problem)? And with a 20 % (1 out of 5) chance of happenning.
    Last edited by Pedrunn; January 14, 2002, 14:22.
    "Kill a man and you are a murder.
    Kill thousands and you are a conquer.
    Kill all and you are a God!"
    -Jean Rostand

  • #2
    Fair enough

    The veteran function can remain the same. It deals with the unit, not the creation effect, so just leave that in. Then for every unit you want created, make one of these handlers (as in the wonder-unit code):

    Code:
    HandleEvent(GrantAdvance) 'Hammurabi' post {
    
    city_t tmpCity;
    int_t tmpPlayer;
    int_t tmpAdvance;
    int_t randomnum;
    
    	tmpAdvance = value[0];
    
    	if(tmpAdvance == AdvanceDB(ADVANCE_IRON_WORKING)) {
    		randomnum = random(4);
    		if(randomnum > 3){
    			tmpPlayer = player[0];
    			int_t i;
    			i = 0;
    			while(i < player[0].cities){
    				GetCityByIndex(tmpPlayer, i, tmpCity);
    				city[0] = tmpCity;
    				if(UnitsAtLocation(city[0].location) != 12){
    					CreateUnit(tmpPlayer, UnitDB(UNIT_HAMMURABI), city[0].location, 0);
    				}
    				else {
    					i = i + 1;
                                    }
                            }
    		}
    	}
    }
    Just change two bits for each one. The name of the handler - in between the two ' s at the top, and then change the unit it refers to in the UnitDB( brackets.

    Then in the veteran function you will need to change some things:
    Code:
    if (tmpNum >= 106 && tmpNum <= 112) {
    Make the numbers in there be the lower 'wonderunit' number, and upper 'wonderunit' number. So it only refers to the wonderunits you want.

    It strikes me that the veteran function is never actually used in the code. I don't know how that got through...
    Add these lines:
    Code:
    HandleEvent(MoveUnits) 'MakeVeteran' pre {
                 location_t tmpLoc;
                 tmpLoc = unit[0].location;
                 tmpPlayer = unit[0].owner;
                 VeteranEffect(tmpLoc, tmpPlayer);
    }

    DISCLAIMER: untried, untested, bugs likely.
    Last edited by Immortal Wombat; January 14, 2002, 14:52.
    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


    • #3
      Re: IW, Could you help with one of yours Slics?

      Is that correct?

      OBS: I guess this definitions will be off:
      city_t tmpCity;
      int_t tmpWonder;

      Or should i leave both there for no reason since they wont interfere?
      Or are they needed?

      Code:
      city_t tmpCity;  
      int_t tmpPlayer;
      int_t tmpWonder; 
      
      void_f VeteranEffect (location_t tmpLoc, int_t tmpPlayer)
      {
      int_t	i;
      unit_t	tmpUnit;
      int_t	tmpNum;
      int_t	numUnits;
      int_t	tmpPlayer2;
      
      	player[0] = tmpPlayer;
      	numUnits = player[0].units;
      	tmpPlayer2 = tmpPlayer;
      	if (IsPlayerAlive(tmpPlayer2)) {
      	// Make all Units non veteran, except Special Units
      		for (i = 0; i < numUnits; i = i + 1) {
      			GetUnitByIndex(tmpPlayer2, i, tmpUnit);
      			tmpNum = tmpUnit.type;
      			if (tmpNum >= 106 && tmpNum <= 112) {                           
      				ToggleVeteran(tmpUnit, 1);
      			} else {
      				ToggleVeteran(tmpUnit, 0);
      			}
      		}
      	}
      	
      	// Make all Units veterans who share the location Alexander, Robin Hood and Richard The Lion Heart
      	tmpNum = GetUnitsAtLocation(tmpLoc);
      	for (i = 0; i < tmpNum; i = i + 1) {
      		GetUnitFromCell(tmpLoc, i, tmpUnit);
      		ToggleVeteran(tmpUnit, 1);
      	}
      }
      
      
      HandleEvent(GrantAdvance) 'Hammurabi' post {
      
      city_t tmpCity;
      int_t tmpPlayer;
      int_t tmpAdvance;
      int_t randomnum;
      
      	tmpAdvance = value[0];
      
      	if(tmpAdvance == AdvanceDB(ADVANCE_IRON_WORKING)) {
      		randomnum = random(4);
      		if(randomnum > 3){
      			tmpPlayer = player[0];
      			int_t i;
      			i = 0;
      			while(i < player[0].cities){
      				GetCityByIndex(tmpPlayer, i, tmpCity);
      				city[0] = tmpCity;
      				if(UnitsAtLocation(city[0].location) != 12){
      					CreateUnit(tmpPlayer, UnitDB(UNIT_HAMMURABI), city[0].location, 0);
      				}
      				else {
      					i = i + 1;
                                      }
                              }
      		}
      	}
      }
      
      HandleEvent(GrantAdvance) 'Alexander' post {
      
      city_t tmpCity;
      int_t tmpPlayer;
      int_t tmpAdvance;
      int_t randomnum;
      
      	tmpAdvance = value[0];
      
      	if(tmpAdvance == AdvanceDB(ADVANCE_INFANTRY_TACTICS)) {
      		randomnum = random(4);
      		if(randomnum > 3){
      			tmpPlayer = player[0];
      			int_t i;
      			i = 0;
      			while(i < player[0].cities){
      				GetCityByIndex(tmpPlayer, i, tmpCity);
      				city[0] = tmpCity;
      				if(UnitsAtLocation(city[0].location) != 12){
      					CreateUnit(tmpPlayer, UnitDB(UNIT_ALEXANDER), city[0].location, 0);
      				}
      				else {
      					i = i + 1;
                                      }
                              }
      		}
      	}
      }
      Last edited by Pedrunn; January 14, 2002, 15:45.
      "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


      • #4
        That is correct.

        The definitions you noted at the top need leaving out! Otherwise they are defined twice, and cause SLIC errors.

        The code is not the fastest way of doing it, but it is the easiest way of doing it so you (and anyone else viewing this thread) can add more of your own.

        One small thing to add. I don't like while-loops and I'm a bit concerned about this one. To be on the safe side, after the CreateUnit line in each handler, add the line
        Code:
        i = i + player[0].cities;
        That will break out of the loop, and prevent any infinitely long delays...

        reminder, you need this in there somewhere (below the void_f VeteranEffect line):
        Code:
        HandleEvent(MoveUnits) 'MakeVeteran' pre {
                     location_t tmpLoc;
                     tmpLoc = unit[0].location;
                     tmpPlayer = unit[0].owner;
                     VeteranEffect(tmpLoc, tmpPlayer);
        }
        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


        • #5
          Don't worry, Ben, it looks like you ripped that while loop straight from the Alexander scenario, meaning either I or Tony Evans wrote it. Since Tony is almost as good a programmer as I am, it has to be high quality code and you should be safe either way

          BTW, you forgot about the chances. To have a 20% change of getting the unit, replace this line (and the ones like it):

          if (tmpAdvance == AdvanceDB(ADVANCE_IRON_WORKING)) {

          with this one:

          if ((tmpAdvance == AdvanceDB(ADVANCE_IRON_WORKING)) && (Random(5) < 1)) {
          Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

          Comment


          • #6
            Originally posted by Locutus
            Don't worry, Ben, it looks like you ripped that while loop straight from the Alexander scenario, meaning either I or Tony Evans wrote it. Since Tony is almost as good a programmer as I am, it has to be high quality code and you should be safe either way

            BTW, you forgot about the chances. To have a 20% change of getting the unit, replace this line (and the ones like it):

            if (tmpAdvance == AdvanceDB(ADVANCE_IRON_WORKING)) {

            with this one:

            if ((tmpAdvance == AdvanceDB(ADVANCE_IRON_WORKING)) && (Random(5) < 1)) {
            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


            • #7
              Originally posted by Locutus
              Don't worry, Ben, it looks like you ripped that while loop straight from the Alexander scenario, meaning either I or Tony Evans wrote it. Since Tony is almost as good a programmer as I am, it has to be high quality code and you should be safe either way
              Yeah, the only thing is that it means you cannot have any veterans apart from the wonderunits...
              BTW, you forgot about the chances. To have a 20% change of getting the unit, replace this line (and the ones like it):
              No I didn't

              Its in there as:
              Code:
              if(tmpAdvance == AdvanceDB(ADVANCE_INFANTRY_TACTICS)) {
              		randomnum = random(4);
              		if(randomnum > 3){
              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


              • #8
                Oops, you're right, I overlooked those odds. I'm not sure they're correct though, I *think* Random(4) returns 0, 1, 2 or 3 but never anything larger (would have to double check that though).
                Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                Comment


                • #9
                  Ah, stupid Activision and their 0s...

                  if(randomnum> 2){

                  then
                  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


                  • #10
                    Actually, your insulting all CS people here: mathematicians always starting counting at 1, programmers and software designers at 0 (naturally the latter is the superior system )...
                    Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                    Comment


                    • #11
                      Stupid software designers...
                      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


                      • #12
                        IW, could you check if the code is right now?

                        Code:
                        void_f VeteranEffect (location_t tmpLoc, int_t tmpPlayer)
                        
                        HandleEvent(MoveUnits) 'MakeVeteran' pre {
                                     location_t tmpLoc;
                                     tmpLoc = unit[0].location;
                                     tmpPlayer = unit[0].owner;
                                     VeteranEffect(tmpLoc, tmpPlayer);
                        }
                        {
                        int_t	i;
                        unit_t	tmpUnit;
                        int_t	tmpNum;
                        int_t	numUnits;
                        int_t	tmpPlayer2;
                        
                        	player[0] = tmpPlayer;
                        	numUnits = player[0].units;
                        	tmpPlayer2 = tmpPlayer;
                        	if (IsPlayerAlive(tmpPlayer2)) {
                        	// Make all Units non veteran, except Special Units
                        		for (i = 0; i < numUnits; i = i + 1) {
                        			GetUnitByIndex(tmpPlayer2, i, tmpUnit);
                        			tmpNum = tmpUnit.type;
                        			if (tmpNum >= 106 && tmpNum <= 112) {                           
                        				ToggleVeteran(tmpUnit, 1);
                        			} else {
                        				ToggleVeteran(tmpUnit, 0);
                        			}
                        		}
                        	}
                        	
                        	// Make all Units veterans who share the location Alexander, Robin Hood and Richard The Lion Heart
                        	tmpNum = GetUnitsAtLocation(tmpLoc);
                        	for (i = 0; i < tmpNum; i = i + 1) {
                        		GetUnitFromCell(tmpLoc, i, tmpUnit);
                        		ToggleVeteran(tmpUnit, 1);
                        	}
                        }
                        
                        
                        HandleEvent(GrantAdvance) 'Hammurabi' post {
                        
                        city_t tmpCity;
                        int_t tmpPlayer;
                        int_t tmpAdvance;
                        int_t randomnum;
                        
                        	tmpAdvance = value[0];
                        
                        	if(tmpAdvance == AdvanceDB(ADVANCE_IRON_WORKING)) {
                        		randomnum = random(4);
                        		if(randomnum > 3){
                        			tmpPlayer = player[0];
                        			int_t i;
                        			i = 0;
                        			while(i < player[0].cities){
                        				GetCityByIndex(tmpPlayer, i, tmpCity);
                        				city[0] = tmpCity;
                        				if(UnitsAtLocation(city[0].location) != 12){
                        					CreateUnit(tmpPlayer, UnitDB(UNIT_HAMMURABI), city[0].location, 0);
                        				}
                        				else {
                        					i = i + 1;
                                                        }
                                                }
                        		}
                        	}
                        }
                        I want to know if only one civ can get this unit or every civ that research the advance can have it (this mean every civ can have a hammurabi in the same game).
                        "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


                        • #13
                          Originally posted by Pedrunn
                          IW, could you check if the code is right now?
                          Not quite
                          Code:
                          void_f VeteranEffect (location_t tmpLoc, int_t tmpPlayer)
                          {
                          int_t	i;
                          unit_t	tmpUnit;
                          int_t	tmpNum;
                          int_t	numUnits;
                          int_t	tmpPlayer2;
                          
                          	player[0] = tmpPlayer;
                          	numUnits = player[0].units;
                          	tmpPlayer2 = tmpPlayer;
                          	if (IsPlayerAlive(tmpPlayer2)) {
                          	// Make all Units non veteran, except Special Units
                          		for (i = 0; i < numUnits; i = i + 1) {
                          			GetUnitByIndex(tmpPlayer2, i, tmpUnit);
                          			tmpNum = tmpUnit.type;
                          			if (tmpNum >= 106 && tmpNum <= 112) {                           
                          				ToggleVeteran(tmpUnit, 1);
                          			} else {
                          				ToggleVeteran(tmpUnit, 0);
                          			}
                          		}
                          	}
                          	
                          	// Make all Units veterans who share the location Alexander, Robin Hood and Richard The Lion Heart
                          	tmpNum = GetUnitsAtLocation(tmpLoc);
                          	for (i = 0; i < tmpNum; i = i + 1) {
                          		GetUnitFromCell(tmpLoc, i, tmpUnit);
                          		ToggleVeteran(tmpUnit, 1);
                          	}
                          }
                          
                          
                          HandleEvent(MoveUnits) 'MakeVeteran' pre {
                                       location_t tmpLoc;
                                       tmpLoc = unit[0].location;
                                       tmpPlayer = unit[0].owner;
                                       VeteranEffect(tmpLoc, tmpPlayer);
                          }
                          
                          
                          HandleEvent(GrantAdvance) 'Hammurabi' post {
                          
                          city_t tmpCity;
                          int_t tmpPlayer;
                          int_t tmpAdvance;
                          int_t randomnum;
                          
                          	tmpAdvance = value[0];
                          
                          	if(tmpAdvance == AdvanceDB(ADVANCE_IRON_WORKING)) {
                          		randomnum = random(4);
                          		if(randomnum >= 3){
                          			tmpPlayer = player[0];
                          			int_t i;
                          			i = 0;
                          			while(i < player[0].cities){
                          				GetCityByIndex(tmpPlayer, i, tmpCity);
                          				city[0] = tmpCity;
                          				if(UnitsAtLocation(city[0].location) != 12){
                          					CreateUnit(tmpPlayer, UnitDB(UNIT_HAMMURABI), city[0].location, 0);
                          				}
                          				else {
                          					i = i + 1;
                                                          }
                                                  }
                          		}
                          	}
                          }
                          [/quote]
                          That is now right.
                          I want to know if only one civ can get this unit or every civ that research the advance can have it (this mean every civ can have a hammurabi in the same game).
                          Every civ can get one. Is this right?
                          If not, add the line
                          Code:
                          DisableTrigger('Hammurabi');
                          below the CreateUnit line. This will mean it only fires once in the game. First person to get there gets the chance of getting it. If you want everyone to have the chance of getting it, leave it as it is.
                          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


                          • #14
                            below the CreateUnit line. This will mean it only fires once in the game. First person to get there gets the chance of getting it. If you want everyone to have the chance of getting it, leave it as it is.
                            Actually i rather have every civ with a chance of the unit in the same game. so i will leave the way it is.
                            Last edited by Pedrunn; January 19, 2002, 09:01.
                            "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


                            • #15
                              Oh Oh!
                              Code:
                              No fuction named UnitsAtLocation
                              I'm getting a message like that for each unit i add.
                              So i changed this fuction by
                              Code:
                              GetUnitsAtLocation
                              and the errors messages disappeared. What i did was right?
                              I'm going to test it now anyway.
                              Last edited by Pedrunn; January 19, 2002, 13:17.
                              "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