Announcement

Collapse
No announcement yet.

SLIC: Logistics

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

  • SLIC: Logistics

    NEED HELP!!!
    this a shell just to express my logic before attempting to SLIC, can anyone check my flow here and offer any needed fixes?


    Code:
    Start turn
    If player = human then
    Get unit type if land
    Then get unit location return value
    Get nearest city and get nearest fort, get lowest value (sptdist)
    If player has advance HORSE return value 5
                                        RAILROAD return 10
                                        AUTOMOBILE return 15
                                        AIR                 return 20    return highest value(advdist)
    Get sptdist divide by advdist = logdist
    Get UNIT GOLD # multiple logdist = gold cost per turn
    Get UNIT pw # multiple logdist = pw cost per turn
    Total gold and pw cost for all units. 
    Subtract from player gold and pw.
    repeat for all land units
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  • #2
    You need to keep the fort loc in an array to allow this script to work.
    "Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
    The BIG MC making ctp2 a much unsafer place.
    Visit the big mc’s website

    Comment


    • #3
      Originally posted by The Big Mc
      You need to keep the fort loc in an array to allow this script to work.
      what do you mean about array? I have to have a separte set of slic that says: find all forts???
      Last edited by Ekmek; December 15, 2004, 17:33.
      Formerly known as "E" on Apolyton

      See me at Civfanatics.com

      Comment


      • #4
        I think he's saying that a FindNearestFort() function called each time would be very time consuming - it would have to scan the map, since fort locations aren't automatically stored like city locations are. If when each fort is built you add the location to a global FORT_LOCS[] array, then you can just scan that array for distances.

        Also, if you check for those advances in reverse order (starting with AIR, ending with HORSE), using elseif statements, you'll get the highest number straight away.

        Code:
        Total gold and pw cost for all units. 
        Subtract from player gold and pw.
        repeat for all land units
        You only need "for all units" once. Either "add the individual one to a running total and subtract it all at the end", or "subtract the individual amount each time and repeat". Probably better the second way, then if there isn't enough gold/pw for the logistics cost, you can injure the unit or something.
        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
          DP
          Last edited by Ekmek; December 23, 2004, 14:24.
          Formerly known as "E" on Apolyton

          See me at Civfanatics.com

          Comment


          • #6
            ok this is my first attempt at (finishing) SLIC. How do I define arrays? and what else did I miss on this. PS since units already have a PW update cost I'm just subtracting gold since you are paying to get that PW to the unit (and food)


            Code:
            if(IsHumanPlayer(player[0])) //logistics is challenge for humans only
            HandleEvent(BeginTurn) 'Startturn' pre {
            for (i = 0; i < GetUnitsAtLocation(tmpLoc); i = i + 1) { 
            int_f FindTheNearestCity( int_t thePlayer, location_t theLocation, int_t theDistance){
            theNearestCity = tmpCity;
            		
            if (HasAdvance(tmpPlayer, ID_ADVANCE_AERODYNAMICS)) {			// if player has airpower,
            		return 25;			
            	} elseif (HasAdvance(tmpPlayer, ID_ADVANCE_AUTOMOBILE)) {
            		return 15;	
            } elseif (HasAdvance(tmpPlayer, ID_ADVANCE_RAILROAD)) {
            		return 10;
            	} elseif (HasAdvance(tmpPlayer, ID_ADVANCE_HORSE)) {
            		return 5;
            		} else {								// if none of above advances present, 
            		return 1;							// basic logistics
            	}
            }
            UNIT_TYPE=UnitDB(UNIT_ARTILLERY) return 5 //unitgold
            
            
            tmpcity-tmpunit/advbonus*unitgold*-1=unitlogistics
            GetTotalUnitlogistics
            AddGold(player[0], - totallogistics cost);	//subtractgold gold
            
            DisableTrigger('StartTurn');			//run once only
            Formerly known as "E" on Apolyton

            See me at Civfanatics.com

            Comment


            • #7
              Can anyone check the above SLIC please?
              Formerly known as "E" on Apolyton

              See me at Civfanatics.com

              Comment


              • #8
                Well the code above doesn't run at all, first we should reoder it a little bit and fix the fomarting of the white space for readibility. Well of course the following code still doesn't work.

                Code:
                HandleEvent(BeginTurn) 'Startturn' pre {
                	if(IsHumanPlayer(player[0])){ //logistics is challenge for humans only
                		for (i = 0; i < GetUnitsAtLocation(tmpLoc); i = i + 1) { 
                			int_f FindTheNearestCity( int_t thePlayer, location_t theLocation, int_t theDistance){
                				theNearestCity = tmpCity;
                		
                				if (HasAdvance(tmpPlayer, ID_ADVANCE_AERODYNAMICS)) {			// if player has airpower,
                					return 25;			
                				}
                				elseif (HasAdvance(tmpPlayer, ID_ADVANCE_AUTOMOBILE)) {
                					return 15;	
                				}
                				elseif (HasAdvance(tmpPlayer, ID_ADVANCE_RAILROAD)) {
                					return 10;
                				}
                				elseif (HasAdvance(tmpPlayer, ID_ADVANCE_HORSE)) {
                					return 5;
                				} 
                				else {								// if none of above advances present, 
                					return 1;						// basic logistics
                				}
                			}
                			UNIT_TYPE=UnitDB(UNIT_ARTILLERY) return 5 //unitgold
                
                
                			tmpcity-tmpunit/advbonus*unitgold*-1=unitlogistics
                			GetTotalUnitlogistics
                			AddGold(player[0], - totallogistics cost);	//subtractgold gold
                
                			DisableTrigger('StartTurn');			//run once only
                		}
                	}
                }
                First thing to consider is that slic is an event driven language so you have to encapsulate your code by an event no statement can be placed outside of an event handle or outside of a function, except for global variable definition.

                Second you cannot define local functions at least I never tried that, and I don't see any sense in it doing it in the middle of a for loop.

                Third you disable the trigger afterwards it has been run once. Well what happens with all the other players in an MP game?

                By the way you should check all the other pieces of slic lying around here.

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

                Comment

                Working...
                X