Results 1 to 8 of 8

Thread: SLIC: Logistics

  1. #1
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    02:41

    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. #2
    The Big Mc
    King The Big Mc's Avatar
    Join Date
    15 Oct 2001
    Location
    Of the universe / England
    Posts
    2,061
    Country
    This is The Big Mc's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    10:41
    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

  3. #3
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    02:41
    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 at 16:33.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  4. #4
    Immortal Wombat
    Prince Immortal Wombat's Avatar
    Join Date
    30 Dec 2000
    Location
    in perpetuity
    Posts
    4,965
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    10:41
    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

  5. #5
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    02:41
    DP
    Last edited by Ekmek; December 23, 2004 at 13:24.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  6. #6
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    02:41
    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

  7. #7
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    02:41
    Can anyone check the above SLIC please?
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  8. #8
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 21, 2013
    Local Time
    12:41

    Post

    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!"

Similar Threads

  1. Logistics
    By Dominus84 in forum Civilization IV General
    Replies: 7
    Last Post: June 17, 2005, 23:46
  2. DESIGN: Another logistics thread
    By Ekmek in forum CtP2 Source Code Project
    Replies: 10
    Last Post: June 17, 2005, 15:03
  3. Logistics
    By :) Smiley in forum Other Games
    Replies: 30
    Last Post: January 8, 2005, 01:54
  4. logistics
    By techumseh in forum Civilization I and Civilization II
    Replies: 10
    Last Post: October 14, 2004, 19:25
  5. Another logistics thread
    By Ekmek in forum CtP2-Creation/AI/Mods/Scenarios-Archive
    Replies: 4
    Last Post: November 1, 2003, 10:54

Visitors found this page by searching for:

slic logistics

Bookmarks

Posting Permissions