Announcement

Collapse
No announcement yet.

Need help making Barrack :-)

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

  • #16
    Thanks for the code. Hope other will include it in their mod pack.

    Comment


    • #17
      quote:

      Originally posted by Locutus on 01-07-2001 08:37 AM
      magma,
      I'm not sure what you're trying to do here, but let me give you some exaple code. Below is how the barrack code could look like in the classic Civ1/2 way: every new unit built in a city is a veteran when a barrack is present. I get the feeling you may be looking for something different though, so if that is the case, let me know what you *are* looking for and I'll see what I can do. Note that following is untested and may contain a few typos or bugs, but the basic idea *should* work.

      Code:
      HandleEvent(CreateUnit) 'BarrackCode' post {	// if a unit is created
      int_t	tmpUnit;
      city_t	tmpCity;
      	tmpUnit = unit[0];	// store the unit that was just built
      	tmpCity= city[0];	// store the city in which it was built
      
      	if (CityIsValid(tmpCity)) {	// if city exits (unit didn't come from ruin or whatever)
      		if (CityHasBuilding(tmpCity, BuildingDB(IMPROVE_BARRACK)) {	// if city has a barrack
      			ToggleVeteran(tmpUnit, 1);	// make unit a veteran;
      		}
      	}
      }


      OK, i just dont get it. I used this code, which seemed to make sense to me, but it wont work. I even fixed the missing ")" on the CityHasBuilding line. I built the barracks in my town, but the new units created dont appear to be vets (no little flag by unit). Or do they only get the vet flag after a battle? I put the code in the scenario.slc file. Also tried it in script.slc. What am i doing wrong?

      ------------------
      History is written by the victor.

      Comment


      • #18
        Odd, I did make another mistake, but I thought that doing that should give an error message, guess I was wrong. Anyway, try replacing BuildingDB(IMPROVE_BARRACK) with "IMPROVE_BARRACK". It's an old CtP1 function and requires the old CtP1 syntax, I forgot about that.
        Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

        Comment


        • #19
          Thanks. Will try it tonight.

          ------------------
          History is written by the victor.

          Comment


          • #20
            no luck. it didnt work. again i'm assuming that the flag will show up upon creation and not only after battles.

            ------------------
            History is written by the victor.

            Comment


            • #21
              Hmm, very odd. I'll need to look into this more closely when I have the time (which will be a while). It can't be that combat is needed because it works fine in the Alexander scenario, all units stacked with Alex get vet-status, combat experience or not.

              One alternative (I have no idea if this will work but it's worth a try) might be to kill the unit immideately when it's created and create a new one of the same type and give that one veteran status, which would look something like this:

              (replace "ToggleVeteran(tmpUnit, 1);" with this)
              Code:
              // if city has barrack {
              	tmpType = value[0];	// I think this returns the unittype, but maybe it's value[1]
              	tmpLoc = tmpCity.location;
              	tmpOwner = tmpCity.owner;
              	Event:KillUnit(tmpUnit);
              	CreateUnit(tmpOwner, tmpType, tmpLoc, 0, tmpUnit);
              	ToggleVeteran(tmpUnit, 1);
              Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

              Comment

              Working...
              X